dataStructures
Class HashTable

java.lang.Object
  |
  +--dataStructures.HashTable

public class HashTable
extends java.lang.Object


Inner Class Summary
protected static class HashTable.HashEntry
           
 
Field Summary
protected  int divisor
           
protected  int size
           
protected  HashTable.HashEntry[] table
           
 
Constructor Summary
HashTable(int theDivisor)
           
 
Method Summary
 java.lang.Object get(java.lang.Object theKey)
           
 boolean isEmpty()
           
static void main(java.lang.String[] args)
          test method
 void output()
          output the hash table
 java.lang.Object put(java.lang.Object theKey, java.lang.Object theElement)
          insert an element with the specified key overwrite old element if there is already an element with the given key
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

divisor

protected int divisor

table

protected HashTable.HashEntry[] table

size

protected int size
Constructor Detail

HashTable

public HashTable(int theDivisor)
Method Detail

isEmpty

public boolean isEmpty()
Returns:
true iff the table is empty

size

public int size()
Returns:
current number of elements in the table

get

public java.lang.Object get(java.lang.Object theKey)
Returns:
element with specified key

put

public java.lang.Object put(java.lang.Object theKey,
                            java.lang.Object theElement)
insert an element with the specified key overwrite old element if there is already an element with the given key
Returns:
old element (if any) with key theKey
Throws:
java.lang.IllegalArgumentException - when the table is full

output

public void output()
output the hash table

main

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