org.exolab.castor.util
Class OrderedHashMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by org.exolab.castor.util.OrderedHashMap
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map

public class OrderedHashMap
extends java.util.HashMap

A very simple extended HashMap, which maintains order via an ArrayList. This class provides similar, though not identical, functionality as the JDK's LinkedHashMap, but works under JDK 1.2 and JDK 1.3. This class is not synchronized, if more than one thread accesses an instance of this class and at least one thread modifies the map, the OrderedHashMap instance must be synchronized via a call to Collections.synchronizedMap method. The #entrySet() and #keySet() methods return unmodifiable sets. The #values() method returns an unmodifiable collection.

Author:
Keith Visco
See Also:
Serialized Form

Constructor Summary
OrderedHashMap()
          Creates a new OrderedHashMap
OrderedHashMap(int initialCapacity)
          Creates a new OrderedHashMap with the given initial capacity
OrderedHashMap(java.util.Map m)
          Creates a new OrderedHashMap with the same entries as the given map.
 
Method Summary
 void clear()
           
 java.lang.Object clone()
           
 java.util.Set entrySet()
          Returns the Map.Entry set for this Map.
 java.util.Set keySet()
          Returns the key set for this Map.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 void putAll(java.util.Map m)
           
 java.lang.Object remove(java.lang.Object key)
           
 java.util.Collection values()
          Returns the set of values for this Map.
 
Methods inherited from class java.util.HashMap
containsKey, containsValue, get, isEmpty, size
 
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()
Creates a new OrderedHashMap


OrderedHashMap

public OrderedHashMap(int initialCapacity)
Creates a new OrderedHashMap with the given initial capacity

Parameters:
initialCapacity -

OrderedHashMap

public OrderedHashMap(java.util.Map m)
Creates a new OrderedHashMap with the same entries as the given map.

Parameters:
m - the Map to initialize this Map with
Method Detail

clear

public void clear()
Specified by:
clear in interface java.util.Map
Overrides:
clear in class java.util.HashMap

clone

public java.lang.Object clone()
Overrides:
clone in class java.util.HashMap

entrySet

public java.util.Set entrySet()
Returns the Map.Entry set for this Map. Note that the returned Set is an unmodifiable Set

Specified by:
entrySet in interface java.util.Map
Overrides:
entrySet in class java.util.HashMap
See Also:
Map.entrySet()

keySet

public java.util.Set keySet()
Returns the key set for this Map. Note that the returned set is an unmodifiable Set

Specified by:
keySet in interface java.util.Map
Overrides:
keySet in class java.util.HashMap
See Also:
Map.keySet()

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map
Overrides:
put in class java.util.HashMap

putAll

public void putAll(java.util.Map m)
Specified by:
putAll in interface java.util.Map
Overrides:
putAll in class java.util.HashMap

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map
Overrides:
remove in class java.util.HashMap

values

public java.util.Collection values()
Returns the set of values for this Map. Note that the returned Collection is unmodifiable.

Specified by:
values in interface java.util.Map
Overrides:
values in class java.util.HashMap
See Also:
Map.values()


Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com