dsto.dfc.collections
Class MicroMap

java.lang.Object
  extended by dsto.dfc.collections.MicroMap

public class MicroMap
extends Object

A small footprint Map-like collection that provides basic put/get/remove functionality for small maps that don't change much. Lookup cost and memory usage scales linearly with entry count.

Version:
$Revision$
Author:
mpp

Constructor Summary
MicroMap()
          Create a map with a default initial capacity before resize.
MicroMap(int initialCapacity)
          Create a map with a given initial capacity before resize.
 
Method Summary
 void clear()
          Remove all entries.
 boolean containsKey(Object key)
          Test if the map contains a key.
 int findIndex(Object key)
          Find the index for a key, or -1 if not found.
 Object get(Object key)
          Find the value with matchinf key.
 Object getKey(int index)
          Get the key for an index (0..size ()).
 Object getValue(int index)
          Get the value for an index (0..size ()).
 Object put(Object key, Object value)
          Add/overwrite a value.
 Object remove(Object key)
          Remove a value.
 int size()
          The number of entries in the map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MicroMap

public MicroMap()
Create a map with a default initial capacity before resize.


MicroMap

public MicroMap(int initialCapacity)
Create a map with a given initial capacity before resize.

Method Detail

clear

public void clear()
Remove all entries.


put

public Object put(Object key,
                  Object value)
Add/overwrite a value.

Parameters:
key - The value key.
value - The value.
Returns:
The old value for key, or null if none.

remove

public Object remove(Object key)
Remove a value.

Parameters:
key - The value key.
Returns:
The old value, or null if none.

get

public Object get(Object key)
Find the value with matchinf key.

Parameters:
key - The key to search for.
Returns:
The value, or null if not found.

containsKey

public boolean containsKey(Object key)
Test if the map contains a key.


size

public int size()
The number of entries in the map.


getKey

public Object getKey(int index)
Get the key for an index (0..size ()).


getValue

public Object getValue(int index)
Get the value for an index (0..size ()).


findIndex

public int findIndex(Object key)
Find the index for a key, or -1 if not found.



Copyright © 2008 Commonwealth of Australia