private Object getValue(int index) { Object object = getRawValue(index); if (object instanceof CollisionLink) { return ((CollisionLink) object).value; } return object; }
private Object getValue(int index) { Object object = getRawValue(index); if (object instanceof CollisionLink) { return ((CollisionLink) object).value; } return object; }
private int findWithCollision(K key, CollisionLink initialEntryValue) { int index; Object entryKey; CollisionLink entryValue = initialEntryValue; while (true) { CollisionLink collisionLink = entryValue; index = collisionLink.next; entryKey = getKey(index); if (compareKeys(key, entryKey)) { return index; } else { Object value = getRawValue(index); if (value instanceof CollisionLink) { entryValue = (CollisionLink) getRawValue(index); } else { return -1; } } } }
private int findWithCollision(K key, CollisionLink initialEntryValue) { int index; Object entryKey; CollisionLink entryValue = initialEntryValue; while (true) { CollisionLink collisionLink = entryValue; index = collisionLink.next; entryKey = getKey(index); if (compareKeys(key, entryKey)) { return index; } else { Object value = getRawValue(index); if (value instanceof CollisionLink) { entryValue = (CollisionLink) getRawValue(index); } else { return -1; } } } }
private int findAndRemoveWithCollision(Object key, CollisionLink initialEntryValue, int initialIndexValue) { int index; Object entryKey; CollisionLink entryValue = initialEntryValue; int lastIndex = initialIndexValue; while (true) { CollisionLink collisionLink = entryValue; index = collisionLink.next; entryKey = getKey(index); if (compareKeys(key, entryKey)) { Object value = getRawValue(index); if (value instanceof CollisionLink) { CollisionLink thisCollisionLink = (CollisionLink) value; setRawValue(lastIndex, new CollisionLink(collisionLink.value, thisCollisionLink.next)); } else { setRawValue(lastIndex, collisionLink.value); } return index; } else { Object value = getRawValue(index); if (value instanceof CollisionLink) { entryValue = (CollisionLink) getRawValue(index); lastIndex = index; } else { return -1; } } } }
private int findAndRemoveWithCollision(Object key, CollisionLink initialEntryValue, int initialIndexValue) { int index; Object entryKey; CollisionLink entryValue = initialEntryValue; int lastIndex = initialIndexValue; while (true) { CollisionLink collisionLink = entryValue; index = collisionLink.next; entryKey = getKey(index); if (compareKeys(key, entryKey)) { Object value = getRawValue(index); if (value instanceof CollisionLink) { CollisionLink thisCollisionLink = (CollisionLink) value; setRawValue(lastIndex, new CollisionLink(collisionLink.value, thisCollisionLink.next)); } else { setRawValue(lastIndex, collisionLink.value); } return index; } else { Object value = getRawValue(index); if (value instanceof CollisionLink) { entryValue = (CollisionLink) getRawValue(index); lastIndex = index; } else { return -1; } } } }
private void setValue(int index, Object newValue) { Object oldValue = getRawValue(index); if (oldValue instanceof CollisionLink) { CollisionLink collisionLink = (CollisionLink) oldValue; setRawValue(index, new CollisionLink(newValue, collisionLink.next)); } else { setRawValue(index, newValue); } }
private void setValue(int index, Object newValue) { Object oldValue = getRawValue(index); if (oldValue instanceof CollisionLink) { CollisionLink collisionLink = (CollisionLink) oldValue; setRawValue(index, new CollisionLink(newValue, collisionLink.next)); } else { setRawValue(index, newValue); } }
private int findAndRemoveHash(Object key) { int hashIndex = getHashIndex(key); int index = getHashArray(hashIndex) - 1; if (index != -1) { Object entryKey = getKey(index); if (compareKeys(key, entryKey)) { Object value = getRawValue(index); int nextIndex = -1; if (value instanceof CollisionLink) { CollisionLink collisionLink = (CollisionLink) value; nextIndex = collisionLink.next; } setHashArray(hashIndex, nextIndex + 1); return index; } else { Object entryValue = getRawValue(index); if (entryValue instanceof CollisionLink) { return findAndRemoveWithCollision(key, (CollisionLink) entryValue, index); } } } return -1; }
private int findAndRemoveHash(Object key) { int hashIndex = getHashIndex(key); int index = getHashArray(hashIndex) - 1; if (index != -1) { Object entryKey = getKey(index); if (compareKeys(key, entryKey)) { Object value = getRawValue(index); int nextIndex = -1; if (value instanceof CollisionLink) { CollisionLink collisionLink = (CollisionLink) value; nextIndex = collisionLink.next; } setHashArray(hashIndex, nextIndex + 1); return index; } else { Object entryValue = getRawValue(index); if (entryValue instanceof CollisionLink) { return findAndRemoveWithCollision(key, (CollisionLink) entryValue, index); } } } return -1; }
private int findHash(K key) { int index = getHashArray(getHashIndex(key)) - 1; if (index != -1) { Object entryKey = getKey(index); if (compareKeys(key, entryKey)) { return index; } else { Object entryValue = getRawValue(index); if (entryValue instanceof CollisionLink) { return findWithCollision(key, (CollisionLink) entryValue); } } } return -1; }
private int findHash(K key) { int index = getHashArray(getHashIndex(key)) - 1; if (index != -1) { Object entryKey = getKey(index); if (compareKeys(key, entryKey)) { return index; } else { Object entryValue = getRawValue(index); if (entryValue instanceof CollisionLink) { return findWithCollision(key, (CollisionLink) entryValue); } } } return -1; }
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); } } }
while (index < totalEntries - 1) { setKey(index, getKey(index + 1)); setRawValue(index, getRawValue(index + 1)); index++;
while (index < totalEntries - 1) { setKey(index, getKey(index + 1)); setRawValue(index, getRawValue(index + 1)); index++;