code: 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 = cells.length - (size + freecells);
      if ((double) gargagecells / cells.length > 0.05D)
      // rehash with same size
      {
        rehash(cells.length);
      } else
      // rehash with increased capacity
      {
        rehash((cells.length << 1) + 1);
      }
    }
docs: Figures out correct size for rehashed set, then does the rehash.