|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--DataStructures.ProbingHashTable
An abstract class implementing the LookupTable interface by means of a hash table. Collisions are resolved by probing.
This class must be extended to implement a particular probing
algorithm for the findIndex method, such as double
hashing or quadratic probing.
findIndex(java.lang.Object),
DoubleHashingTable,
QuadraticProbingTable| Inner Class Summary | |
protected static class |
ProbingHashTable.Entry
A class of objects returned by iteration over entries. |
| Inner classes inherited from class DataStructures.LookupTable |
LookupTable.Entry |
| Field Summary | |
protected ProbingHashTable.Entry[] |
table
the underlying table of hash entries |
| Method Summary | |
void |
add(java.lang.Object key,
java.lang.Object value)
Adds the specified entry to the table. |
boolean |
contains(java.lang.Object key)
Returns true if the table contains an entry for this key. |
protected abstract int |
findIndex(java.lang.Object key)
Abstract method returning the index in the table of a key, if present, or the index at which to insert it, if absent. |
boolean |
isEmpty()
Tests if the table is empty. |
java.util.Iterator |
iterator()
Iterates over the table's entries. |
java.lang.Object |
lookup(java.lang.Object key)
Returns the value associated with the specified key. |
void |
remove(java.lang.Object key)
Removes the entry corresponding to the key. |
int |
size()
Returns the number of entries in the table. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected ProbingHashTable.Entry[] table
| Method Detail |
protected abstract int findIndex(java.lang.Object key)
key - the key to search forpublic final boolean isEmpty()
LookupTableisEmpty in interface LookupTableDataStructures.LookupTablepublic final int size()
LookupTablesize in interface LookupTableDataStructures.LookupTablepublic final boolean contains(java.lang.Object key)
LookupTablecontains in interface LookupTableDataStructures.LookupTablekey - the key to be searched for
public final void add(java.lang.Object key,
java.lang.Object value)
LookupTableadd in interface LookupTableDataStructures.LookupTablekey - the key of the entryvalue - the value of the entrypublic final void remove(java.lang.Object key)
LookupTableremove in interface LookupTableDataStructures.LookupTablekey - the key of the entry to be removedpublic final java.lang.Object lookup(java.lang.Object key)
LookupTablelookup in interface LookupTableDataStructures.LookupTablekey - the key to be searched forNoSuchElementException - if key is not presentpublic java.util.Iterator iterator()
LookupTableiterator in interface LookupTableDataStructures.LookupTableLookupTable.Entry
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||