/** * Rehashes the contents of the receiver into a new table with a smaller or larger capacity. This method is called * automatically when the number of keys in the receiver exceeds the high water mark or falls below the low water * mark. */ protected void rehash(int newCapacity) { int oldCapacity = table.length; //if (oldCapacity == newCapacity) return; int[] oldTable = table; long[] oldValues = values; byte[] oldState = state; this.table = new int[newCapacity]; this.values = new long[newCapacity]; this.state = new byte[newCapacity]; this.lowWaterMark = chooseLowWaterMark(newCapacity, this.minLoadFactor); this.highWaterMark = chooseHighWaterMark(newCapacity, this.maxLoadFactor); this.freeEntries = newCapacity - this.distinct; // delta for (int i = oldCapacity; i-- > 0;) { if (oldState[i] == FULL) { int element = oldTable[i]; int index = indexOfInsertion(element); this.table[index] = element; this.values[index] = oldValues[i]; this.state[index] = FULL; } } }
/** * Rehashes the contents of the receiver into a new table with a smaller or larger capacity. This method is called * automatically when the number of keys in the receiver exceeds the high water mark or falls below the low water * mark. */ protected void rehash(int newCapacity) { int oldCapacity = table.length; //if (oldCapacity == newCapacity) return; int[] oldTable = table; long[] oldValues = values; byte[] oldState = state; this.table = new int[newCapacity]; this.values = new long[newCapacity]; this.state = new byte[newCapacity]; this.lowWaterMark = chooseLowWaterMark(newCapacity, this.minLoadFactor); this.highWaterMark = chooseHighWaterMark(newCapacity, this.maxLoadFactor); this.freeEntries = newCapacity - this.distinct; // delta for (int i = oldCapacity; i-- > 0;) { if (oldState[i] == FULL) { int element = oldTable[i]; int index = indexOfInsertion(element); this.table[index] = element; this.values[index] = oldValues[i]; this.state[index] = FULL; } } }
/** * Rehashes the contents of the receiver into a new table with a smaller or larger capacity. This method is called * automatically when the number of keys in the receiver exceeds the high water mark or falls below the low water * mark. */ protected void rehash(int newCapacity) { int oldCapacity = table.length; //if (oldCapacity == newCapacity) return; int[] oldTable = table; long[] oldValues = values; byte[] oldState = state; this.table = new int[newCapacity]; this.values = new long[newCapacity]; this.state = new byte[newCapacity]; this.lowWaterMark = chooseLowWaterMark(newCapacity, this.minLoadFactor); this.highWaterMark = chooseHighWaterMark(newCapacity, this.maxLoadFactor); this.freeEntries = newCapacity - this.distinct; // delta for (int i = oldCapacity; i-- > 0;) { if (oldState[i] == FULL) { int element = oldTable[i]; int index = indexOfInsertion(element); this.table[index] = element; this.values[index] = oldValues[i]; this.state[index] = FULL; } } }