Opus5
Class AbstractHashTable

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

public abstract class AbstractHashTable
extends AbstractSearchableContainer
implements HashTable

The AbstractHashTable class is the base class from which all concrete hash and scatter table classes are derived. This abstract class provides default implementations for various methods declared in the HashTable interface.

Version:
$Id: AbstractHashTable.java,v 3.2 1998/07/28 13:00:41 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.
See Also:
HashTable

Fields inherited from class Opus5.AbstractContainer
count
 
Fields inherited from interface Opus5.HashTable
copyright
 
Constructor Summary
AbstractHashTable()
           
 
Method Summary
protected  int f(java.lang.Object object)
          Returns the hashcode for the specified object.
protected  int g(int x)
          Hashes an integer using the division method of hashing.
abstract  int getLength()
          Returns the length of this hash table.
 double getLoadFactor()
          Computes the current load factor for this hash table.
protected  int h(java.lang.Object object)
          Hashes the specified object using the composition of the methods f and g.
 
Methods inherited from class Opus5.AbstractContainer
accept, getCount, hashCode, isEmpty, isFull, toString
 
Methods inherited from class Opus5.AbstractObject
compare, compareTo, 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.SearchableContainer
find, insert, isMember, withdraw
 
Methods inherited from interface Opus5.Container
accept, getCount, getEnumeration, isEmpty, isFull, purge
 
Methods inherited from interface Opus5.Comparable
compare, isEQ, isGE, isGT, isLE, isLT, isNE
 

Constructor Detail

AbstractHashTable

public AbstractHashTable()
Method Detail

getLength

public abstract int getLength()
Returns the length of this hash table.
Returns:
The length of this hash table.

f

protected final int f(java.lang.Object object)
Returns the hashcode for the specified object. Implemented as follows:
 return object.hashCode ();
 
Parameters:
object - The object the hashcode of which is returned.
Returns:
The hashcode for the specified object.

g

protected final int g(int x)
Hashes an integer using the division method of hashing. Implemented as follows:
 return Math.abs (x) % getLength ();
 
Parameters:
x - The integer to be hashed.
Returns:
A positive integer in the interval [0,Length()-1].

h

protected final int h(java.lang.Object object)
Hashes the specified object using the composition of the methods f and g. Implemented as follows:
 return g(f(object));
 
Parameters:
object - The object to be hashed.
Returns:
A positive integer in the interval [0,Length()-1].

getLoadFactor

public final double getLoadFactor()
Computes the current load factor for this hash table. Implemented as follows:
 return (double) getCount () / getLength ();
 
Specified by:
getLoadFactor in interface HashTable
Returns:
The current load factor for this hash table.