gnu.kawa.util
Class GeneralHashTable<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by gnu.kawa.util.AbstractHashTable<HashNode<K,V>,K,V>
          extended by gnu.kawa.util.GeneralHashTable<K,V>
All Implemented Interfaces:
java.util.Map<K,V>
Direct Known Subclasses:
IdentityHashTable, NameLookup

public class GeneralHashTable<K,V>
extends AbstractHashTable<HashNode<K,V>,K,V>

A generic hash table. Supports deletions, and re-allocates the table when too big. The equivalence relation can be customized.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class gnu.kawa.util.AbstractHashTable
DEFAULT_INITIAL_SIZE, mask, num_bindings, table
 
Constructor Summary
GeneralHashTable()
           
GeneralHashTable(int capacity)
           
 
Method Summary
protected  HashNode<K,V>[] allocEntries(int n)
          Allocate Entry[n].
protected  int getEntryHashCode(HashNode<K,V> entry)
          Extract hash-code from Entry.
protected  HashNode<K,V> getEntryNext(HashNode<K,V> entry)
          Extract next Entry in same hash-bucket.
 HashNode<K,V> getNode(java.lang.Object key)
          This override helps Kawa type-inference - for example in srfi69.scm.
protected  HashNode<K,V> makeEntry(K key, int hash, V value)
          Allocate a new node in the hash table.
protected  void setEntryNext(HashNode<K,V> entry, HashNode<K,V> next)
          Set next Entry in same hash-bucket.
 
Methods inherited from class gnu.kawa.util.AbstractHashTable
clear, entrySet, get, get, hash, hashToIndex, matches, matches, put, put, rehash, remove, size
 
Methods inherited from class java.util.AbstractMap
clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeneralHashTable

public GeneralHashTable()

GeneralHashTable

public GeneralHashTable(int capacity)
Method Detail

getEntryHashCode

protected int getEntryHashCode(HashNode<K,V> entry)
Description copied from class: AbstractHashTable
Extract hash-code from Entry.

Specified by:
getEntryHashCode in class AbstractHashTable<HashNode<K,V>,K,V>

getEntryNext

protected HashNode<K,V> getEntryNext(HashNode<K,V> entry)
Description copied from class: AbstractHashTable
Extract next Entry in same hash-bucket.

Specified by:
getEntryNext in class AbstractHashTable<HashNode<K,V>,K,V>

setEntryNext

protected void setEntryNext(HashNode<K,V> entry,
                            HashNode<K,V> next)
Description copied from class: AbstractHashTable
Set next Entry in same hash-bucket.

Specified by:
setEntryNext in class AbstractHashTable<HashNode<K,V>,K,V>

allocEntries

protected HashNode<K,V>[] allocEntries(int n)
Description copied from class: AbstractHashTable
Allocate Entry[n].

Specified by:
allocEntries in class AbstractHashTable<HashNode<K,V>,K,V>

makeEntry

protected HashNode<K,V> makeEntry(K key,
                                  int hash,
                                  V value)
Allocate a new node in the hash table.

Specified by:
makeEntry in class AbstractHashTable<HashNode<K,V>,K,V>

getNode

public HashNode<K,V> getNode(java.lang.Object key)
This override helps Kawa type-inference - for example in srfi69.scm.

Overrides:
getNode in class AbstractHashTable<HashNode<K,V>,K,V>