|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectDictionary<K,D>
Hashtable<K,D>
K
- The type of the keys. Note that Object.hashCode()
and Object.equals(Object)
must
conform to each other, i.e. whenever o1.equals(o2) == true
then o1.hashCode() == o2.hashCode()
must
hold. Otherwise, this data-structure will have unexpected behaviour.D
- The type of the data.public class Hashtable<K,D>
A hashtable implementation of the Map-interface.
Conflicts are resolved by allowing multiple entries per
array element. Automatic reallocation of the table is
performed if the table is too empty or too crowded.
Standard access methods like insertion, deletion, etc. all
have amortized cost O(1) if a good hash-function, i.e. Object.hashCode()
is used.
Constructor Summary | |
---|---|
Hashtable()
Constructs an empty hashtable with default initial tablesize (10). |
|
Hashtable(int s)
Constructs an empty hashtable with initial tablesize s. |
Method Summary | |
---|---|
void |
delete(K k)
Removes the entry which stores the data for the key k. |
D |
find(K k)
Looks up the data stored under the key k. |
void |
insert(K k,
D d)
Associates the data d to the key k in this map. |
boolean |
iselement(K k)
Checks whether the key k is present in this map. |
Iterator<K,D> |
iterator()
Creates a new iterator over all associations between keys and data. |
int |
size()
Returns the size of this map, i.e. the number of keys, under which data is stored in O(1). |
Methods inherited from class Dictionary |
---|
array, isempty, print, simpleiterator |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Hashtable(int s)
s
- The initial size of the table.public Hashtable()
Method Detail |
---|
public Iterator<K,D> iterator()
Map
iterator
in interface Map<K,D>
iterator
in class Dictionary<K,D>
Iterator
over all keys with
associated data.public void insert(K k, D d)
insert
in interface Map<K,D>
insert
in class Dictionary<K,D>
k
- The key to store.d
- The data associated to the key k.Map.insert(Object, Object)
public void delete(K k)
delete
in interface Map<K,D>
delete
in class Dictionary<K,D>
k
- The key to delete with its associated data.Map.delete(Object)
public D find(K k)
find
in interface Map<K,D>
find
in class Dictionary<K,D>
k
- The key under which the data is stored.
Map.find(Object)
public boolean iselement(K k)
iselement
in interface Map<K,D>
iselement
in class Dictionary<K,D>
k
- The key to look for.
Map.iselement(Object)
public int size()
size
in interface Map<K,D>
size
in class Dictionary<K,D>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |