@Test public void testContains() { set.add("hei"); Assert.assertTrue("set doesn't think just added object is contained", set.contains("hei")); Assert.assertTrue("set thinks not added object is contained", !set.contains("hei2")); }
@Override public boolean contains(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; } return objects[index] != null; }
CompactHashSet extends java.util.AbstractSet<E> { @Override public boolean contains(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; } return objects[index] != null; } }
CompactHashSet extends java.util.AbstractSet<E> { @Override public boolean contains(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; } return objects[index] != null; } CompactHashSet();  CompactHashSet(int size);  CompactHashSet(Collection<E> c); }
CompactHashSet extends java.util.AbstractSet<E> { @Override public boolean contains(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; } return objects[index] != null; } 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 contains(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; } return objects[index] != null; } 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();  }