Opus5
Class ChainedHashTable

java.lang.Object
  |
  +--Opus5.AbstractObject
        |
        +--Opus5.AbstractContainer
              |
              +--Opus5.AbstractSearchableContainer
                    |
                    +--Opus5.AbstractHashTable
                          |
                          +--Opus5.ChainedHashTable
All Implemented Interfaces:
Comparable, Container, HashTable, SearchableContainer

public class ChainedHashTable
extends AbstractHashTable

A chained hash table implemented using an array of linked lists.

Version:
$Id: ChainedHashTable.java,v 3.4 1998/07/28 12:25:30 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.
See Also:
HashTable

Field Summary
protected  LinkedList[] array
          An array of linked lists.
 
Fields inherited from class Opus5.AbstractContainer
count
 
Fields inherited from interface Opus5.HashTable
copyright
 
Constructor Summary
ChainedHashTable(int length)
          Constructs a ChainedHashTable with the specified length.
 
Method Summary
 void accept(Visitor visitor)
          Accepts the specified visitor and makes it visit all the objects in this chained hash table.
protected  int compareTo(Comparable arg)
          Compares this chained hash table with the specified comparable object.
 Comparable find(Comparable object)
          Returns an object in this chained hash table that matches the specified comparable object.
 Enumeration getEnumeration()
          Returns an enumeration that enumerates all the object contained in this chained hash table.
 int getLength()
          Returns the length of the array.
 void insert(Comparable object)
          Inserts the specified comparable object into this chained hash table.
 boolean isMember(Comparable object)
          Tests whether the specified object is in this chained hash table.
 void purge()
          Purges this chained hash table, making it empty.
 void withdraw(Comparable object)
          Withdraws the specified comparable object from this chained hash table.
 
Methods inherited from class Opus5.AbstractHashTable
f, g, getLoadFactor, h
 
Methods inherited from class Opus5.AbstractContainer
getCount, hashCode, isEmpty, isFull, toString
 
Methods inherited from class Opus5.AbstractObject
compare, equals, isEQ, isGE, isGT, isLE, isLT, isNE
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Opus5.Container
getCount, isEmpty, isFull
 
Methods inherited from interface Opus5.Comparable
compare, isEQ, isGE, isGT, isLE, isLT, isNE
 

Field Detail

array

protected LinkedList[] array
An array of linked lists.
Constructor Detail

ChainedHashTable

public ChainedHashTable(int length)
Constructs a ChainedHashTable with the specified length.
Parameters:
length - The desired length.
Method Detail

getLength

public int getLength()
Returns the length of the array.
Overrides:
getLength in class AbstractHashTable
Returns:
the length of the array.

purge

public void purge()
Purges this chained hash table, making it empty.

insert

public void insert(Comparable object)
Inserts the specified comparable object into this chained hash table.
Parameters:
object - The object to insert.

withdraw

public void withdraw(Comparable object)
Withdraws the specified comparable object from this chained hash table.
Parameters:
object - The object to withdraw.

isMember

public boolean isMember(Comparable object)
Tests whether the specified object is in this chained hash table.
Parameters:
object - The object for which to look.
Returns:
True if the object is in this chained hash table; false otherwise.

find

public Comparable find(Comparable object)
Returns an object in this chained hash table that matches the specified comparable object.
Parameters:
object - The object to match.
Returns:
The object in this chained hash table that matches the specified object; null if there is no match.

accept

public void accept(Visitor visitor)
Accepts the specified visitor and makes it visit all the objects in this chained hash table.
Overrides:
accept in class AbstractContainer
Parameters:
visitor - The visitor to accept.

getEnumeration

public Enumeration getEnumeration()
Returns an enumeration that enumerates all the object contained in this chained hash table.
Returns:
An enumeration that enumerates all the object contained in this chained hash table.

compareTo

protected int compareTo(Comparable arg)
Compares this chained hash table with the specified comparable object.
Overrides:
compareTo in class AbstractObject
Parameters:
arg - The comparable object to which this chained hash table is compared. This method is not implemented.
Throws:
MethodNotImplemented - Always.