|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uwcse.collections.SimpleOpenHashMap
Implementation of the SimpleMap interface via an open hashing scheme. The table is arranged as an array of SimpleLists, which are used as growable buckets. The table automatically resizes when the "load" exceeds an internal load factor. In this context, load is defined as the average number of items per bucket. Keeping this small (as in under 10) provides a reasonable time vs. space tradeoff. Very load factors will result in unacceptable space performance; while large load factors will result in unacceptable lookup performance. Because of the growable nature of the table, the fundamental operations (get, put, remove) execute in constant time. Allocating an iterator also occurs in constant time.
Constructor Summary | |
SimpleOpenHashMap()
|
Method Summary | |
void |
clear()
Remove all associations from the map. |
boolean |
containsKey(java.lang.Object key)
Answer true iff the given key exists in the map. |
boolean |
containsValue(java.lang.Object value)
Answer true iff the given value exists in the map. |
java.lang.Object |
get(java.lang.Object key)
Answer the value associated with the given key. |
boolean |
isEmpty()
Answer (size() == 0) |
SimpleIterator |
keys()
Answer a SimpleIterator over the keys in the association. |
static void |
main(java.lang.String[] args)
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Associate the given key and value, replacing any previous association for the given key. |
java.lang.Object |
remove(java.lang.Object key)
Remove the association (if any) for the given key. |
int |
size()
Answer the number of associations in the map. |
java.lang.String |
toString()
|
SimpleIterator |
values()
Answer a SimpleIterator over the values in the association. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SimpleOpenHashMap()
Method Detail |
public void clear()
SimpleMap
clear
in interface SimpleMap
public boolean containsKey(java.lang.Object key)
SimpleMap
containsKey
in interface SimpleMap
public boolean containsValue(java.lang.Object value)
SimpleMap
containsValue
in interface SimpleMap
public java.lang.Object get(java.lang.Object key)
SimpleMap
get
in interface SimpleMap
uwcse.collections.SimpleMap
public boolean isEmpty()
SimpleMap
isEmpty
in interface SimpleMap
public SimpleIterator keys()
SimpleMap
keys
in interface SimpleMap
public static void main(java.lang.String[] args)
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
SimpleMap
put
in interface SimpleMap
uwcse.collections.SimpleMap
public java.lang.Object remove(java.lang.Object key)
SimpleMap
remove
in interface SimpleMap
uwcse.collections.SimpleMap
public int size()
SimpleMap
size
in interface SimpleMap
public java.lang.String toString()
toString
in class java.lang.Object
public SimpleIterator values()
SimpleMap
values
in interface SimpleMap
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |