private void addStash (int key) { if (stashSize == stashCapacity) { // Too many pushes occurred and the stash is full, increase the table size. resize(capacity << 1); addResize(key); return; } // Store key in the stash. int index = capacity + stashSize; keyTable[index] = key; stashSize++; size++; }
private void addStash (int key) { if (stashSize == stashCapacity) { // Too many pushes occurred and the stash is full, increase the table size. resize(capacity << 1); addResize(key); return; } // Store key in the stash. int index = capacity + stashSize; keyTable[index] = key; stashSize++; size++; }
private void resize (int newSize) { int oldEndIndex = capacity + stashSize; capacity = newSize; threshold = (int)(newSize * loadFactor); mask = newSize - 1; hashShift = 31 - Integer.numberOfTrailingZeros(newSize); stashCapacity = Math.max(3, (int)Math.ceil(Math.log(newSize)) * 2); pushIterations = Math.max(Math.min(newSize, 8), (int)Math.sqrt(newSize) / 8); int[] oldKeyTable = keyTable; keyTable = new int[newSize + stashCapacity]; int oldSize = size; size = hasZeroValue ? 1 : 0; stashSize = 0; if (oldSize > 0) { for (int i = 0; i < oldEndIndex; i++) { int key = oldKeyTable[i]; if (key != EMPTY) addResize(key); } } }
private void resize (int newSize) { int oldEndIndex = capacity + stashSize; capacity = newSize; threshold = (int)(newSize * loadFactor); mask = newSize - 1; hashShift = 31 - Integer.numberOfTrailingZeros(newSize); stashCapacity = Math.max(3, (int)Math.ceil(Math.log(newSize)) * 2); pushIterations = Math.max(Math.min(newSize, 8), (int)Math.sqrt(newSize) / 8); int[] oldKeyTable = keyTable; keyTable = new int[newSize + stashCapacity]; int oldSize = size; size = hasZeroValue ? 1 : 0; stashSize = 0; if (oldSize > 0) { for (int i = 0; i < oldEndIndex; i++) { int key = oldKeyTable[i]; if (key != EMPTY) addResize(key); } } }
private void addStash (int key) { if (stashSize == stashCapacity) { // Too many pushes occurred and the stash is full, increase the table size. resize(capacity << 1); addResize(key); return; } // Store key in the stash. int index = capacity + stashSize; keyTable[index] = key; stashSize++; size++; }
private void resize (int newSize) { int oldEndIndex = capacity + stashSize; capacity = newSize; threshold = (int)(newSize * loadFactor); mask = newSize - 1; hashShift = 31 - Integer.numberOfTrailingZeros(newSize); stashCapacity = Math.max(3, (int)Math.ceil(Math.log(newSize)) * 2); pushIterations = Math.max(Math.min(newSize, 8), (int)Math.sqrt(newSize) / 8); int[] oldKeyTable = keyTable; keyTable = new int[newSize + stashCapacity]; int oldSize = size; size = hasZeroValue ? 1 : 0; stashSize = 0; if (oldSize > 0) { for (int i = 0; i < oldEndIndex; i++) { int key = oldKeyTable[i]; if (key != EMPTY) addResize(key); } } }