/** * Empties the hash. */ @Override public void clear() { modCount++; size = 0; freeSlots = capacity(); removedSlots = 0; }
/** * Empties the hash. */ @Override public void clear() { modCount++; size = 0; freeSlots = capacity(); removedSlots = 0; }
@Override public final double currentLoad() { return ((double) (size + removedSlots)) / (double) capacity(); }
@Override public final double currentLoad() { return ((double) (size + removedSlots)) / (double) capacity(); }
private boolean tryRehashForExpansion(int newCapacity) { // No sense in rehashing for expansion if we already reached Java array // size limit. if (newCapacity > capacity() || removedSlots > 0) { rehash(newCapacity); return true; } else { if (freeSlots < minFreeSlots) minFreeSlots = (freeSlots + 1) / 2; return false; } }
private boolean tryRehashForExpansion(int newCapacity) { // No sense in rehashing for expansion if we already reached Java array // size limit. if (newCapacity > capacity() || removedSlots > 0) { rehash(newCapacity); return true; } else { if (freeSlots < minFreeSlots) minFreeSlots = (freeSlots + 1) / 2; return false; } }
@Override public boolean shrink() { int newCapacity = targetCapacity(size); if (removedSlots > 0 || newCapacity < capacity()) { rehash(newCapacity); return true; } else { return false; } }
@Override public boolean shrink() { int newCapacity = targetCapacity(size); if (removedSlots > 0 || newCapacity < capacity()) { rehash(newCapacity); return true; } else { return false; } }
private int grownCapacity() { return nearestGreaterCapacity(configWrapper.grow(capacity()), size, doubleSizedArrays()); } }
private int grownCapacity() { return nearestGreaterCapacity(configWrapper.grow(capacity()), size, doubleSizedArrays()); } }