@Test public void testRemove() { set.add("hei"); Assert.assertTrue("remove didn't know element was in set", set.remove("hei")); Assert.assertTrue("removing only element in set does not make it empty", set.isEmpty()); }
@Override public boolean remove(Object o) { if (o == null) o = nullObject; int hash = o.hashCode(); int index = (hash & 0x7FFFFFFF) % objects.length; int offset = 1; while(objects[index] != null && !(objects[index].hashCode() == hash && objects[index].equals(o))) { index = ((index + offset) & 0x7FFFFFFF) % objects.length; offset = offset*2 + 1; if (offset == -1) offset = 2; } if (objects[index] != null) { objects[index] = (E) deletedObject; modCount++; elements--; return true; } else return false; }
CompactHashSet extends java.util.AbstractSet<E> { @Override public boolean remove(Object o) { if (o == null) o = nullObject; int hash = o.hashCode(); int index = (hash & 0x7FFFFFFF) % objects.length; int offset = 1; while(objects[index] != null && !(objects[index].hashCode() == hash && objects[index].equals(o))) { index = ((index + offset) & 0x7FFFFFFF) % objects.length; offset = offset*2 + 1; if (offset == -1) offset = 2; } if (objects[index] != null) { objects[index] = (E) deletedObject; modCount++; elements--; return true; } else return false; } }
CompactHashSet extends java.util.AbstractSet<E> { @Override public boolean remove(Object o) { if (o == null) o = nullObject; int hash = o.hashCode(); int index = (hash & 0x7FFFFFFF) % objects.length; int offset = 1; while(objects[index] != null && !(objects[index].hashCode() == hash && objects[index].equals(o))) { index = ((index + offset) & 0x7FFFFFFF) % objects.length; offset = offset*2 + 1; if (offset == -1) offset = 2; } if (objects[index] != null) { objects[index] = (E) deletedObject; modCount++; elements--; return true; } else return false; } CompactHashSet();  CompactHashSet(int size);  CompactHashSet(Collection<E> c); }
CompactHashSet extends java.util.AbstractSet<E> { @Override public boolean remove(Object o) { if (o == null) o = nullObject; int hash = o.hashCode(); int index = (hash & 0x7FFFFFFF) % objects.length; int offset = 1; while(objects[index] != null && !(objects[index].hashCode() == hash && objects[index].equals(o))) { index = ((index + offset) & 0x7FFFFFFF) % objects.length; offset = offset*2 + 1; if (offset == -1) offset = 2; } if (objects[index] != null) { objects[index] = (E) deletedObject; modCount++; elements--; return true; } else return false; } CompactHashSet();  CompactHashSet(int size);  CompactHashSet(Collection<E> c); @Override Iterator<E> iterator(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean add(Object o); @Override boolean remove(Object o); @Override void clear(); @Override Object[] toArray(); @Override T[] toArray(T[] a); void dump(); }
CompactHashSet extends java.util.AbstractSet<E> { @Override public boolean remove(Object o) { if (o == null) o = nullObject; int hash = o.hashCode(); int index = (hash & 0x7FFFFFFF) % objects.length; int offset = 1; while(objects[index] != null && !(objects[index].hashCode() == hash && objects[index].equals(o))) { index = ((index + offset) & 0x7FFFFFFF) % objects.length; offset = offset*2 + 1; if (offset == -1) offset = 2; } if (objects[index] != null) { objects[index] = (E) deletedObject; modCount++; elements--; return true; } else return false; } CompactHashSet();  CompactHashSet(int size);  CompactHashSet(Collection<E> c); @Override Iterator<E> iterator(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override boolean add(Object o); @Override boolean remove(Object o); @Override void clear(); @Override Object[] toArray(); @Override T[] toArray(T[] a); void dump();  }