private void grow() { int entriesLength = entries.length; int newSize = (entriesLength >> 1) + Math.max(MIN_CAPACITY_INCREASE, entriesLength >> 2); if (newSize > MAX_ELEMENT_COUNT) { throw new UnsupportedOperationException("map grown too large!"); } Object[] newEntries = new Object[newSize << 1]; System.arraycopy(entries, 0, newEntries, 0, entriesLength); entries = newEntries; if ((entriesLength < LARGE_HASH_THRESHOLD && newEntries.length >= LARGE_HASH_THRESHOLD) || (entriesLength < VERY_LARGE_HASH_THRESHOLD && newEntries.length > VERY_LARGE_HASH_THRESHOLD)) { // Rehash in order to change number of bits reserved for hash indices. createHash(); } }
private void grow() { int entriesLength = entries.length; int newSize = (entriesLength >> 1) + Math.max(MIN_CAPACITY_INCREASE, entriesLength >> 2); if (newSize > MAX_ELEMENT_COUNT) { throw new UnsupportedOperationException("map grown too large!"); } Object[] newEntries = new Object[newSize << 1]; System.arraycopy(entries, 0, newEntries, 0, entriesLength); entries = newEntries; if ((entriesLength < LARGE_HASH_THRESHOLD && newEntries.length >= LARGE_HASH_THRESHOLD) || (entriesLength < VERY_LARGE_HASH_THRESHOLD && newEntries.length > VERY_LARGE_HASH_THRESHOLD)) { // Rehash in order to change number of bits reserved for hash indices. createHash(); } }
this.hashArray = null; } else { createHash();
this.hashArray = null; } else { createHash();
putHashEntry(key, nextEntryIndex, rehashOnCollision); } else if (totalEntries > getHashThreshold()) { createHash();
putHashEntry(key, nextEntryIndex, rehashOnCollision); } else if (totalEntries > getHashThreshold()) { createHash();
private void putHashEntry(Object key, int entryIndex, boolean rehashOnCollision) { int hashIndex = getHashIndex(key); int oldIndex = getHashArray(hashIndex) - 1; if (oldIndex != -1 && rehashOnCollision) { this.createHash(); return; } setHashArray(hashIndex, entryIndex + 1); Object value = getRawValue(entryIndex); if (oldIndex != -1) { assert entryIndex != oldIndex : "this cannot happend and would create an endless collision link cycle"; if (value instanceof CollisionLink) { CollisionLink collisionLink = (CollisionLink) value; setRawValue(entryIndex, new CollisionLink(collisionLink.value, oldIndex)); } else { setRawValue(entryIndex, new CollisionLink(getRawValue(entryIndex), oldIndex)); } } else { if (value instanceof CollisionLink) { CollisionLink collisionLink = (CollisionLink) value; setRawValue(entryIndex, collisionLink.value); } } }
private void putHashEntry(Object key, int entryIndex, boolean rehashOnCollision) { int hashIndex = getHashIndex(key); int oldIndex = getHashArray(hashIndex) - 1; if (oldIndex != -1 && rehashOnCollision) { this.createHash(); return; } setHashArray(hashIndex, entryIndex + 1); Object value = getRawValue(entryIndex); if (oldIndex != -1) { assert entryIndex != oldIndex : "this cannot happend and would create an endless collision link cycle"; if (value instanceof CollisionLink) { CollisionLink collisionLink = (CollisionLink) value; setRawValue(entryIndex, new CollisionLink(collisionLink.value, oldIndex)); } else { setRawValue(entryIndex, new CollisionLink(getRawValue(entryIndex), oldIndex)); } } else { if (value instanceof CollisionLink) { CollisionLink collisionLink = (CollisionLink) value; setRawValue(entryIndex, collisionLink.value); } } }