Class HashTableTest.IntEntry
java.lang.Object
|
+--HashTableTest.IntEntry
- All Implemented Interfaces:
- HashTableEntry
- Enclosing class:
- HashTableTest
- protected static class HashTableTest.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 |
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 |
value
protected java.lang.Integer value
- The single Integer value of this hash table entry
HashTableTest.IntEntry
public HashTableTest.IntEntry(int value)
- Construct an entry with the given int value.
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