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 removeNullEntry() { containsNull = false; key[n] = (0); size--; fixPointers(n); if (n > minN && size < maxFill / 4 && n > DEFAULT_INITIAL_SIZE) rehash(n / 2); return true; }
/** * Removes the the last key in iteration order. * * @return the last key. * @throws NoSuchElementException * is this set is empty. */ public long removeLastLong() { if (size == 0) throw new NoSuchElementException(); final int pos = last; // Abbreviated version of fixPointers(pos) last = (int) (link[pos] >>> 32); if (0 <= last) { // Special case of SET_NEXT(link[last], -1) link[last] |= -1 & 0xFFFFFFFFL; } final long k = key[pos]; size--; if (((k) == (0))) { containsNull = false; key[n] = (0); } else shiftKeys(pos); if (n > minN && size < maxFill / 4 && n > DEFAULT_INITIAL_SIZE) rehash(n / 2); return k; } private void moveIndexToFirst(final int i) {
private boolean removeEntry(final int pos) { size--; fixPointers(pos); shiftKeys(pos); if (n > minN && size < maxFill / 4 && n > DEFAULT_INITIAL_SIZE) rehash(n / 2); return true; } private boolean removeNullEntry() {
/** * Removes the first key in iteration order. * * @return the first key. * @throws NoSuchElementException * is this set is empty. */ public long removeFirstLong() { if (size == 0) throw new NoSuchElementException(); final int pos = first; // Abbreviated version of fixPointers(pos) first = (int) link[pos]; if (0 <= first) { // Special case of SET_PREV(link[first], -1) link[first] |= (-1 & 0xFFFFFFFFL) << 32; } final long k = key[pos]; size--; if (((k) == (0))) { containsNull = false; key[n] = (0); } else shiftKeys(pos); if (n > minN && size < maxFill / 4 && n > DEFAULT_INITIAL_SIZE) rehash(n / 2); return k; } /**
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; } /**
rehash(arraySize(size + 1, f)); if (ASSERTS) checkTable();
rehash(arraySize(size, f)); if (ASSERTS) checkTable();
rehash(arraySize(size, f)); if (ASSERTS) checkTable();