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 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() {
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 void ensureCapacity(final int capacity) { final int needed = arraySize(capacity, f); if (needed > n) rehash(needed); } private void tryCapacity(final long capacity) {
@Override public boolean add(final float k) { int pos; if ((Float.floatToIntBits(k) == 0)) { if (containsNull) return false; containsNull = true; } else { float curr; final float[] key = this.key; // The starting point. if (!(Float.floatToIntBits( curr = key[pos = it.unimi.dsi.fastutil.HashCommon.mix(it.unimi.dsi.fastutil.HashCommon.float2int(k)) & mask]) == 0)) { if ((Float.floatToIntBits(curr) == Float.floatToIntBits(k))) return false; while (!(Float.floatToIntBits(curr = key[pos = (pos + 1) & mask]) == 0)) if ((Float.floatToIntBits(curr) == Float.floatToIntBits(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;