/** * INTERNAL: Figures out correct size for rehashed set, then does * the rehash. */ protected void rehash() { // do we need to increase capacity, or are there so many // deleted objects hanging around that rehashing to the same // size is sufficient? if 5% (arbitrarily chosen number) of // cells can be freed up by a rehash, we do it. int gargagecells = objects.length - (elements + freecells); if (gargagecells / (double) objects.length > 0.05) // rehash with same size rehash(objects.length); else // rehash with increased capacity rehash(objects.length*2 + 1); }
rehash(); return true; } else // was there already