private void internalInit(int capacity) { maxSize = maxSize(capacity); allocateArrays(capacity); }
@Override public boolean shrink() { int newCapacity = targetCapacity(size); if (newCapacity < capacity()) { rehash(newCapacity); return true; } else { return false; } }
@Override public void clear() { super.clear(); Object[] tab = table; for (int i = 0; i < tab.length; i += 2) { tab[i] = FREE; tab[i + 1] = null; } }
final void postInsertHook() { if (++size > maxSize) { tryRehashForExpansion(grownCapacity()); } }
void move(ParallelKVDoubleQHash hash) { super.copy(hash); table = hash.table(); }
final void init(HashConfigWrapper configWrapper, int size, byte freeValue ) { this.freeValue = freeValue; // calls allocateArrays, fill keys with this.freeValue => assign it before super.init(configWrapper, size); }
private int grownCapacity() { return nearestGreaterCapacity(configWrapper.grow(capacity()), size, doubleSizedArrays()); } }
final void init(HashConfigWrapper configWrapper, int size) { this.configWrapper = configWrapper; this.size = 0; internalInit(targetCapacity(size)); }
private boolean isMaxCapacity(int capacity) { return QHashCapacities.isMaxCapacity(capacity, doubleSizedArrays()); }
/** * This method just increments modification count (see {@link #modCount()}) * and calls {@link #internalInit(int)}. Should be called by subclasses * in {@link #rehash(int)} implementation. */ final void initForRehash(int newCapacity) { modCount++; internalInit(newCapacity); }
private int maxSize(int capacity) { // No sense in trying to rehash after each insertion // if the capacity is already reached the limit. return !isMaxCapacity(capacity) ? configWrapper.maxSize(capacity) : capacity - 1; }
final void copy(QHash hash) { configWrapper = hash.configWrapper(); size = hash.size(); int capacity = hash.capacity(); maxSize = maxSize(capacity); }
void move(SeparateKVObjQHash hash) { super.copy(hash); set = hash.keys(); }
final void init(HashConfigWrapper configWrapper, int size, short freeValue ) { this.freeValue = freeValue; // calls allocateArrays, fill keys with this.freeValue => assign it before super.init(configWrapper, size); }
final void postInsertHook() { if (++size > maxSize) { tryRehashForExpansion(grownCapacity()); } }
private int grownCapacity() { return nearestGreaterCapacity(configWrapper.grow(capacity()), size, doubleSizedArrays()); } }
final void init(HashConfigWrapper configWrapper, int size) { this.configWrapper = configWrapper; this.size = 0; internalInit(targetCapacity(size)); }
private int targetCapacity(int size) { return QHashCapacities.capacity(configWrapper, size, doubleSizedArrays()); }