DataStructures
Class QuadraticProbingHashTable

java.lang.Object
  |
  +--DataStructures.QuadraticProbingHashTable

public class QuadraticProbingHashTable
extends java.lang.Object

Probing table implementation of hash tables. Note that all "matching" is based on the equals method.


Constructor Summary
QuadraticProbingHashTable()
          Construct the hash table.
QuadraticProbingHashTable(int size)
          Construct the hash table.
 
Method Summary
 Hashable find(Hashable x)
          Find an item in the hash table.
static int hash(java.lang.String key, int tableSize)
          A hash routine for String objects.
 void insert(Hashable x)
          Insert into the hash table.
static void main(java.lang.String[] args)
           
 void makeEmpty()
          Make the hash table logically empty.
 void remove(Hashable x)
          Remove from the hash table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuadraticProbingHashTable

public QuadraticProbingHashTable()
Construct the hash table.

QuadraticProbingHashTable

public QuadraticProbingHashTable(int size)
Construct the hash table.
Parameters:
size - the approximate initial size.
Method Detail

insert

public void insert(Hashable x)
Insert into the hash table. If the item is already present, do nothing.
Parameters:
x - the item to insert.

remove

public void remove(Hashable x)
Remove from the hash table.
Parameters:
x - the item to remove.

find

public Hashable find(Hashable x)
Find an item in the hash table.
Parameters:
x - the item to search for.
Returns:
the matching item.

makeEmpty

public void makeEmpty()
Make the hash table logically empty.

hash

public static int hash(java.lang.String key,
                       int tableSize)
A hash routine for String objects.
Parameters:
key - the String to hash.
tableSize - the size of the hash table.
Returns:
the hash value.

main

public static void main(java.lang.String[] args)