private boolean removeNullEntry() { containsNull = false; key[n] = (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() {
@Override public boolean add(final double k) { int pos; if ((Double.doubleToLongBits(k) == 0)) { if (containsNull) return false; containsNull = true; } else { double curr; final double[] key = this.key; // The starting point. if (!(Double.doubleToLongBits( curr = key[pos = (int) it.unimi.dsi.fastutil.HashCommon.mix(Double.doubleToRawLongBits(k)) & mask]) == 0)) { if ((Double.doubleToLongBits(curr) == Double.doubleToLongBits(k))) return false; while (!(Double.doubleToLongBits(curr = key[pos = (pos + 1) & mask]) == 0)) if ((Double.doubleToLongBits(curr) == Double.doubleToLongBits(k))) return false; } key[pos] = k; } if (size++ >= maxFill) rehash(arraySize(size + 1, f)); if (ASSERTS) checkTable(); return true; } /**
/** * 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; } /**
return true; try { rehash(l); } catch (OutOfMemoryError cantDoIt) { return false;