code: public void compact()
      {
          final int idealCapacity = (int)Math.round(size() * (1.0 / loadFactor));
          rehash(findNextPositivePowerOfTwo(Math.max(MIN_CAPACITY, idealCapacity)));
      }
docs: Compact the backing arrays by rehashing with a capacity just larger than current size
  and giving consideration to the load factor.