public class QuadraticProbingHashTable<K,V>
extends java.lang.Object
Probing table implementation of hash tables. Note that all "matching" is based on the equals method.
Constructor and Description |
---|
QuadraticProbingHashTable()
Construct the hash table.
|
QuadraticProbingHashTable(int size)
Construct the hash table.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(K key)
Search for an item in the hash table.
|
V |
get(K key)
Find an item in the hash table.
|
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(K key,
V value)
Insert into the hash table.
|
void |
remove(K key)
Remove from the hash table.
|
public QuadraticProbingHashTable()
public QuadraticProbingHashTable(int size)
size
- the approximate initial size.public void put(K key, V value)
key
- the item to insert.public void remove(K key)
key
- the item to remove.public boolean contains(K key)
key
- the item to search for.public V get(K key)
key
- the item to search for.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)