private boolean removeNullEntry() { containsNull = false; key[n] = ((short) 0); size--; if (n > minN && size < maxFill / 4 && n > DEFAULT_INITIAL_SIZE) rehash(n / 2); return true; }
private void ensureCapacity(final int capacity) { final int needed = arraySize(capacity, f); if (needed > n) rehash(needed); } private void tryCapacity(final long capacity) {
private void tryCapacity(final long capacity) { final int needed = (int) Math.min(1 << 30, Math.max(2, HashCommon.nextPowerOfTwo((long) Math.ceil(capacity / f)))); if (needed > n) rehash(needed); } @Override
private boolean removeEntry(final int pos) { size--; shiftKeys(pos); if (n > minN && size < maxFill / 4 && n > DEFAULT_INITIAL_SIZE) rehash(n / 2); return true; } private boolean removeNullEntry() {
return true; try { rehash(l); } catch (OutOfMemoryError cantDoIt) { return false;
/** * Rehashes this set, making the table as small as possible. * * <p> * This method rehashes the table to the smallest size satisfying the load * factor. It can be used when the set will not be changed anymore, so to * optimize access speed and size. * * <p> * If the table size is already the minimum possible, this method does nothing. * * @return true if there was enough memory to trim the set. * @see #trim(int) */ public boolean trim() { final int l = arraySize(size, f); if (l >= n || size > maxFill(l, f)) return true; try { rehash(l); } catch (OutOfMemoryError cantDoIt) { return false; } return true; } /**
@Override public boolean add(final short k) { int pos; if (((k) == ((short) 0))) { if (containsNull) return false; containsNull = true; } else { short curr; final short[] key = this.key; // The starting point. if (!((curr = key[pos = (it.unimi.dsi.fastutil.HashCommon.mix((k))) & mask]) == ((short) 0))) { if (((curr) == (k))) return false; while (!((curr = key[pos = (pos + 1) & mask]) == ((short) 0))) if (((curr) == (k))) return false; } key[pos] = k; } if (size++ >= maxFill) rehash(arraySize(size + 1, f)); if (ASSERTS) checkTable(); return true; } /**