Package gnu.kawa.util
Class AbstractHashTable<Entry extends Map.Entry<K,V>,K,V>
java.lang.Object
java.util.AbstractMap<K,V>
gnu.kawa.util.AbstractHashTable<Entry,K,V>
- All Implemented Interfaces:
Map<K,V>
- Direct Known Subclasses:
AbstractWeakHashTable,GeneralHashTable,Namespace,WeakIdentityHashMap
An abstract hash map from K to V.
The entries are represented by an Entry type parameter.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Entry[]allocEntries(int n) Allocate Entry[n].voidclear()entrySet()Find value for given key.Find value for given key.protected abstract intgetEntryHashCode(Entry entry) Extract hash-code from Entry.protected abstract EntrygetEntryNext(Entry entry) Extract next Entry in same hash-bucket.Find Entry for given key.getOrDefault(Object key, V defaultValue) intCalculate hash code of a key.protected inthashToIndex(int hash) Map hash-code to bucket index in table.protected abstract EntryAllocate a new node in the hash table.protected booleanTrue if an Entry matches a key.protected booleanCompare two keys for equivalence.protected voidrehash()protected abstract voidsetEntryNext(Entry entry, Entry next) Set next Entry in same hash-bucket.intsize()Methods 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
-
Field Details
-
table
-
mask
protected int mask -
num_bindings
protected int num_bindings -
DEFAULT_INITIAL_SIZE
public static final int DEFAULT_INITIAL_SIZE- See Also:
-
-
Constructor Details
-
AbstractHashTable
public AbstractHashTable() -
AbstractHashTable
public AbstractHashTable(int capacity)
-
-
Method Details
-
getEntryHashCode
Extract hash-code from Entry. -
getEntryNext
Extract next Entry in same hash-bucket. -
setEntryNext
Set next Entry in same hash-bucket. -
allocEntries
Allocate Entry[n]. -
makeEntry
Allocate a new node in the hash table. -
hash
Calculate hash code of a key. -
hashToIndex
protected int hashToIndex(int hash) Map hash-code to bucket index in table. -
matches
True if an Entry matches a key. -
matches
Compare two keys for equivalence. Override this and thehash(Object)method if you want a different equivalence relation. -
get
Find value for given key. Return null if not found. -
getNode
Find Entry for given key. Return null if not found. -
get
Find value for given key. Return defaultValue if not found. -
getOrDefault
-
rehash
protected void rehash() -
put
-
put
-
remove
-
clear
public void clear() -
size
public int size() -
entrySet
-