/** * 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. */ @SuppressWarnings("unchecked") protected void rehash(int newCapacity) { int oldCapacity = table.length; //if (oldCapacity == newCapacity) return; Object[] oldTable = table; short[] oldValues = values; byte[] oldState = state; this.table = new Object[newCapacity]; this.values = new short[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) { Object element = oldTable[i]; int index = indexOfInsertion((T)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. */ @SuppressWarnings("unchecked") protected void rehash(int newCapacity) { int oldCapacity = table.length; //if (oldCapacity == newCapacity) return; Object[] oldTable = table; short[] oldValues = values; byte[] oldState = state; this.table = new Object[newCapacity]; this.values = new short[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) { Object element = oldTable[i]; int index = indexOfInsertion((T)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. */ @SuppressWarnings("unchecked") protected void rehash(int newCapacity) { int oldCapacity = table.length; //if (oldCapacity == newCapacity) return; Object[] oldTable = table; short[] oldValues = values; byte[] oldState = state; this.table = new Object[newCapacity]; this.values = new short[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) { Object element = oldTable[i]; int index = indexOfInsertion((T)element); this.table[index] = element; this.values[index] = oldValues[i]; this.state[index] = FULL; } } }