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
public abstract class AbstractHashTable<Entry extends Map.Entry<K,V>, K, V>
extends AbstractMap<K,V>
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 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 AbstractMap
clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, valuesMethods inherited from interface 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
-
setEntryNext
-
allocEntries
Allocate Entry[n]. -
makeEntry
-
hash
Calculate hash code of a key. -
hashToIndex
protected int hashToIndex(int hash) Map hash-code to bucket index in table. -
matches
-
matches
Compare two keys for equivalence. Override this and thehash(Object)method if you want a different equivalence relation. -
get
-
getNode
-
get
-
getOrDefault
-
rehash
protected void rehash() -
put
-
put
-
remove
-
clear
-
size
-
entrySet
-