|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.mhhe.clrs2e.ChainedHashTable
Implements a hash table with chaining, as described on page 226 of
Introduction to Algorithms, Second edition. Elements
inserted must implement the Comparable interface.
Hash keys are based on the Java hashCode method
applied to objects and then run through the multiplication method
on pages 231-232.
| Field Summary | |
private com.mhhe.clrs2e.MultiplicationMethod |
hasher
The class for the hash function used. |
private com.mhhe.clrs2e.SentinelDLLDictionary[] |
table
The hash table is an array of linked lists. |
| Constructor Summary | |
ChainedHashTable()
Creates a new chained hash table with 16 entries. |
|
ChainedHashTable(int m)
Creates a new chained hash table of a given size. |
|
| Method Summary | |
void |
delete(java.lang.Object handle)
Removes an element from a chained hash table. |
private void |
initChainedHashTable(int m)
Initializes a chained hash table of a given size. |
java.lang.Object |
insert(java.lang.Comparable o)
Inserts an element into a chained hash table. |
java.lang.Object |
search(java.lang.Comparable k)
Searches a chained hash table for an element with a given key. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private com.mhhe.clrs2e.SentinelDLLDictionary[] table
private com.mhhe.clrs2e.MultiplicationMethod hasher
| Constructor Detail |
public ChainedHashTable()
public ChainedHashTable(int m)
m - The size of the chained hash table.| Method Detail |
private void initChainedHashTable(int m)
m - The size of the chained hash table.public java.lang.Object insert(java.lang.Comparable o)
insert in interface Dictionaryo - The element to insert.
public void delete(java.lang.Object handle)
delete in interface Dictionaryhandle - A handle to the element to remove.public java.lang.Object search(java.lang.Comparable k)
search in interface Dictionaryk - The key being searched for.
null if
there is no match.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||