public class SeparateChainingHashTable<E>
extends java.lang.Object
Separate chaining table implementation of hash tables. Note that all "matching" is based on the equals method.
Constructor and Description |
---|
SeparateChainingHashTable()
Construct the hash table.
|
SeparateChainingHashTable(int size)
Construct the hash table.
|
Modifier and Type | Method and Description |
---|---|
E |
get(E x)
Find an item in the hash table.
|
LinkedListItr<E> |
getList(E x) |
static int |
hashString(java.lang.String key,
int tableSize)
A hash routine for String objects.
|
static void |
main(java.lang.String[] args) |
void |
makeEmpty()
Make the hash table logically empty.
|
void |
put(E x)
Insert into the hash table.
|
void |
remove(E x)
Remove from the hash table.
|
public SeparateChainingHashTable()
public SeparateChainingHashTable(int size)
size
- approximate table size.public void put(E x)
x
- the item to insert.public void remove(E x)
x
- the item to remove.public E get(E x)
x
- the item to search for.public LinkedListItr<E> getList(E x)
public void makeEmpty()
public static int hashString(java.lang.String key, int tableSize)
key
- the String to hash.tableSize
- the size of the hash table.public static void main(java.lang.String[] args)