|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--asd_library.hash.HashTable
Implementation of hash table
Field Summary | |
protected int |
currentSize
|
protected boolean[] |
isActive
|
protected boolean |
isRehashable
|
protected int |
k
|
protected java.lang.Comparable[] |
table
The array of elements. |
Constructor Summary | |
HashTable()
Costructs the hash table. |
|
HashTable(int size)
Costructs the hash table. |
|
HashTable(int size,
boolean rehash)
Costructs the hash table. |
Method Summary | |
java.lang.Object |
find(java.lang.Comparable key)
Returns the value to which this map maps the specified key. |
static int |
hash(java.lang.String key,
int tableSize)
A hash routine for String objects. |
java.lang.Object |
insert(java.lang.Comparable key)
Inserts the key x in this dictionary. |
void |
makeEmpty()
Make the hash table logically empty. |
java.lang.Comparable |
remove(java.lang.Comparable key)
Removes the mapping for this key from this dictionary if it is present |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.Comparable[] table
protected boolean[] isActive
protected int currentSize
protected boolean isRehashable
protected int k
Constructor Detail |
public HashTable()
public HashTable(int size)
size
- the initial size of the hash table.public HashTable(int size, boolean rehash)
size
- the initial size of the hash table.rehash
- true if the table can be expanded, false otherwise.Method Detail |
public java.lang.Object insert(java.lang.Comparable key)
insert
in interface Dictionary_adt
key
- the element to insert
public java.lang.Comparable remove(java.lang.Comparable key)
remove
in interface Dictionary_adt
key
- the element to remove.public java.lang.Object find(java.lang.Comparable key)
find
in interface Dictionary_adt
key
- key whose associated value is to be returned.
public static int hash(java.lang.String key, int tableSize)
key
- the String to hash.tableSize
- the size of the hash table.
public void makeEmpty()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |