Class HashTableTestSimple.IntEntry

java.lang.Object
  |
  +--HashTableTestSimple.IntEntry
All Implemented Interfaces:
HashTableEntry
Enclosing class:
HashTableTestSimple

protected static class HashTableTestSimple.IntEntry
extends java.lang.Object
implements HashTableEntry

Inner class IntEntry is a very simple implementation of HashTableEntry with a single Integer field. This field serves as both the key and value for the entry.


Field Summary
protected  java.lang.Integer value
          The single Integer value of this hash table entry
 
Constructor Summary
HashTableTestSimple.IntEntry(int value)
          Construct an entry with the given int value.
 
Method Summary
 java.lang.Object getKey()
          Return the key value of this entry, which is just the single Integer value.
 int hash(java.lang.Object key, int tableSize)
          Compute the hash function of this entry as (key + 2) % tableSize.
 java.lang.String toString()
          Return the value of this entry as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected java.lang.Integer value
The single Integer value of this hash table entry
Constructor Detail

HashTableTestSimple.IntEntry

public HashTableTestSimple.IntEntry(int value)
Construct an entry with the given int value.
Method Detail

getKey

public java.lang.Object getKey()
Return the key value of this entry, which is just the single Integer value.
Specified by:
getKey in interface HashTableEntry

hash

public int hash(java.lang.Object key,
                int tableSize)
Compute the hash function of this entry as (key + 2) % tableSize. The "+ 2" part is to facilitate testing by having values hash to some other table location than themselves.
Specified by:
hash in interface HashTableEntry

toString

public java.lang.String toString()
Return the value of this entry as a string.
Overrides:
toString in class java.lang.Object