CompactHashSet extends java.util.AbstractSet<E> { protected void rehash() { int gargagecells = objects.length - (elements + freecells); if (gargagecells / (double) objects.length > 0.05) rehash(objects.length); else rehash(objects.length*2 + 1); } 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();  }
@Test public void testRehash() { set.add("hei"); set.add("hei2"); set.add("hei3"); set.add("hei4"); set.add("bei"); set.add("bei2"); set.add("bei3"); set.add("bei4"); set.add("_hei"); set.add("_hei2"); set.add("_hei3"); set.add("_hei4"); set.add("_bei"); set.add("_bei2"); set.add("_bei3"); set.add("_bei4"); set.add("$_hei"); set.add("$_hei2"); set.add("$_hei3"); set.add("$_hei4"); set.add("$_bei"); set.add("$_bei2"); set.add("$_bei3"); set.add("$_bei4"); Assert.assertTrue("set(24).size() != 24", set.size() == 24); Assert.assertTrue("contained object lost", set.contains("hei")); Assert.assertTrue("contained object lost", set.contains("hei2")); Assert.assertTrue("contained object lost", set.contains("hei3")); Assert.assertTrue("contained object lost", set.contains("hei4")); Assert.assertTrue("contained object lost", set.contains("_hei")); Assert.assertTrue("contained object lost", set.contains("_hei2")); Assert.assertTrue("contained object lost", set.contains("_hei3")); Assert.assertTrue("contained object lost", set.contains("_hei4")); Assert.assertTrue("contained object lost", set.contains("$_hei")); Assert.assertTrue("contained object lost", set.contains("$_hei2")); Assert.assertTrue("contained object lost", set.contains("$_hei3")); Assert.assertTrue("contained object lost", set.contains("$_hei4")); }