gnu.kawa.util

Class GeneralHashTable


public class GeneralHashTable
extends java.lang.Object

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

Constructor Summary

GeneralHashTable()
GeneralHashTable(int capacity)

Method Summary

Object
get(Object key, Object defaultValue)
int
hash(Object key)
Calculate hash code of a key.
int
hash(HashNode node)
protected HashNode
makeEntry(Object key, int hash, Object value)
Allocate a new node in the hash table.
boolean
matches(Object value1, Object value2)
Compare two keys for equivalence.
boolean
matches(Object key, int hash, HashNode node)
void
put(Object key, Object value)
void
put(Object key, int hash, Object value)
void
remove(Object key)

Constructor Details

GeneralHashTable

public GeneralHashTable()

GeneralHashTable

public GeneralHashTable(int capacity)

Method Details

get

public Object get(Object key,
                  Object defaultValue)

hash

public int hash(Object key)
Calculate hash code of a key. You may need to override this if you override the matches method.

hash

public int hash(HashNode node)

makeEntry

protected HashNode makeEntry(Object key,
                             int hash,
                             Object value)
Allocate a new node in the hash table.

matches

public boolean matches(Object value1,
                       Object value2)
Compare two keys for equivalence. Override this and the hash(Object) method if you want a different equivalence relation.

matches

public boolean matches(Object key,
                       int hash,
                       HashNode node)

put

public void put(Object key,
                Object value)

put

public void put(Object key,
                int hash,
                Object value)

remove

public void remove(Object key)