Package gnu.kawa.util
Class AbstractWeakHashTable<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
gnu.kawa.util.AbstractHashTable<AbstractWeakHashTable.WEntry<K,V>,K,V>
gnu.kawa.util.AbstractWeakHashTable<K,V>
- All Implemented Interfaces:
Map<K,V>
public abstract class AbstractWeakHashTable<K,V>
extends AbstractHashTable<AbstractWeakHashTable.WEntry<K,V>,K,V>
A hash table with weakly referenced keys and values.
Unlike java.util.WeakHashMap, this is useful when a
value object contain a strong reference to the corresponding keys.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields inherited from class gnu.kawa.util.AbstractHashTable
DEFAULT_INITIAL_SIZE, mask, num_bindings, table -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AbstractWeakHashTable.WEntry<K,V>[] allocEntries(int n) Allocate Entry[n].protected voidcleanup()Find value for given key.protected intExtract hash-code from Entry.protected AbstractWeakHashTable.WEntry<K, V> getEntryNext(AbstractWeakHashTable.WEntry<K, V> entry) Extract next Entry in same hash-bucket.protected abstract KgetKeyFromValue(V value) protected VgetValueIfMatching(AbstractWeakHashTable.WEntry<K, V> node, Object key) intCalculate hash code of a key.protected AbstractWeakHashTable.WEntry<K, V> Allocate a new node in the hash table.protected voidsetEntryNext(AbstractWeakHashTable.WEntry<K, V> entry, AbstractWeakHashTable.WEntry<K, V> next) Set next Entry in same hash-bucket.protected booleanvaluesEqual(V oldValue, V newValue) Methods inherited from class gnu.kawa.util.AbstractHashTable
clear, entrySet, get, getNode, getOrDefault, hashToIndex, matches, matches, put, rehash, remove, sizeMethods inherited from class java.util.AbstractMap
clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
AbstractWeakHashTable
public AbstractWeakHashTable() -
AbstractWeakHashTable
public AbstractWeakHashTable(int capacity)
-
-
Method Details
-
getKeyFromValue
-
getEntryHashCode
Description copied from class:AbstractHashTableExtract hash-code from Entry.- Specified by:
getEntryHashCodein classAbstractHashTable<AbstractWeakHashTable.WEntry<K,V>, K, V>
-
getEntryNext
Description copied from class:AbstractHashTableExtract next Entry in same hash-bucket.- Specified by:
getEntryNextin classAbstractHashTable<AbstractWeakHashTable.WEntry<K,V>, K, V>
-
setEntryNext
protected void setEntryNext(AbstractWeakHashTable.WEntry<K, V> entry, AbstractWeakHashTable.WEntry<K, V> next) Description copied from class:AbstractHashTableSet next Entry in same hash-bucket.- Specified by:
setEntryNextin classAbstractHashTable<AbstractWeakHashTable.WEntry<K,V>, K, V>
-
allocEntries
Description copied from class:AbstractHashTableAllocate Entry[n].- Specified by:
allocEntriesin classAbstractHashTable<AbstractWeakHashTable.WEntry<K,V>, K, V>
-
getValueIfMatching
-
get
Description copied from class:AbstractHashTableFind value for given key. Return defaultValue if not found.- Overrides:
getin classAbstractHashTable<AbstractWeakHashTable.WEntry<K,V>, K, V>
-
hash
Description copied from class:AbstractHashTableCalculate hash code of a key.- Overrides:
hashin classAbstractHashTable<AbstractWeakHashTable.WEntry<K,V>, K, V>
-
valuesEqual
-
makeEntry
Description copied from class:AbstractHashTableAllocate a new node in the hash table.- Specified by:
makeEntryin classAbstractHashTable<AbstractWeakHashTable.WEntry<K,V>, K, V>
-
put
-
cleanup
protected void cleanup()
-