gov.nih.nlm.util
Class OrderedHashMap

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended bygov.nih.nlm.util.OrderedHashMap
All Implemented Interfaces:
Cloneable, Map, Serializable

public class OrderedHashMap
extends HashMap

A HashMap that maintains the order in which elements were added.

Author:
Stephanie Halbeisen
See Also:
Serialized Form

Constructor Summary
OrderedHashMap()
          Instantiates an empty OrderedHashMap.
OrderedHashMap(int capacity)
          Instantiates an empty OrderedHashMap with the specified capacity.
OrderedHashMap(int capacity, float load_factor)
          Instantiates an empty OrderedHashMap with the specified capacity and load factor.
OrderedHashMap(Map map)
          Instantiates an OrderedHashMap from an existing Map.
 
Method Summary
 void clear()
          Clears the map.
 Object getKey(int index)
          Returns the Object key for a specified index.
 Object getValue(int index)
          Returns the Object value for a specified index.
 List orderedKeySet()
          Returns the key set as an ordered List.
 Object put(Object key, Object value)
          Adds a key/value pair.
 void putAll(Map map)
          Adds all elements from the specified Map.
 Object remove(Object key)
          Removes the mapping for the specified key.
 
Methods inherited from class java.util.HashMap
clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

OrderedHashMap

public OrderedHashMap()
Instantiates an empty OrderedHashMap.


OrderedHashMap

public OrderedHashMap(int capacity)
Instantiates an empty OrderedHashMap with the specified capacity.

Parameters:
capacity - the initial capacity

OrderedHashMap

public OrderedHashMap(int capacity,
                      float load_factor)
Instantiates an empty OrderedHashMap with the specified capacity and load factor.

Parameters:
capacity - the initial capacity
load_factor - the load factor

OrderedHashMap

public OrderedHashMap(Map map)
Instantiates an OrderedHashMap from an existing Map.

Parameters:
map - the map
Method Detail

put

public Object put(Object key,
                  Object value)
Adds a key/value pair.

Parameters:
key - the key
value - the value
Returns:
Object

putAll

public void putAll(Map map)
Adds all elements from the specified Map.

Parameters:
map - the Map

getKey

public Object getKey(int index)
Returns the Object key for a specified index.

Parameters:
index - an index into the ordered list
Returns:
the key as an Object

getValue

public Object getValue(int index)
Returns the Object value for a specified index.

Parameters:
index - an index into the ordered list
Returns:
the value as an Object

remove

public Object remove(Object key)
Removes the mapping for the specified key.

Parameters:
key - the key
Returns:
the mapping

clear

public void clear()
Clears the map.


orderedKeySet

public List orderedKeySet()
Returns the key set as an ordered List.

Returns:
the key set as an ordered List


Copyright ©2005