edu.mit.ai.psg.utilities
Class ArrayMap
java.lang.Object
|
+--java.util.AbstractMap
|
+--edu.mit.ai.psg.utilities.ArrayMap
- public class ArrayMap
- extends AbstractMap
- implements Cloneable
ArrayMap is a implementation of Map which uses a
simple trimmed array of alternating keys and values. Looking up a
key is linear in the size of the map. Trimming minimizes space
consumption at the cost of speed when adding or removing elements.
Thus, ArrayMap is useful for applications with large numbers of
small maps which are rarely resized. It is also easier to browse
in a debugger than a hash table or tree, as debuggers can display
the storage array as {key1, val1, key2, val2, ...}. The iterator
is simple, and backed by the array; it may omit or repeat items if
elements are removed or added during the iteration.
ArrayMap
public ArrayMap()
ArrayMap
public ArrayMap(Map initElements)
ArrayMap
public ArrayMap(Object[] initElements)
- initialize with array containing key1, val1, key2, val2, ...
size
public int size()
- Overrides:
- size in class AbstractMap
isEmpty
public boolean isEmpty()
- Overrides:
- isEmpty in class AbstractMap
get
public Object get(Object key)
- Overrides:
- get in class AbstractMap
put
public Object put(Object key,
Object newVal)
- Overrides:
- put in class AbstractMap
remove
public Object remove(Object key)
- Overrides:
- remove in class AbstractMap
clone
public Object clone()
- Overrides:
- clone in class Object
entrySet
public Set entrySet()
- Overrides:
- entrySet in class AbstractMap