org.clapper.util.misc
Class OrderedHashMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- org.clapper.util.misc.OrderedHashMap<K,V>
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.util.Map<K,V>
Deprecated.Please use java.util.LinkedHashMap, instead
public class OrderedHashMap<K,V> extends java.util.HashMap<K,V> implements java.lang.Cloneable, java.io.SerializableAn OrderedHashMap is a java.util.HashMap with one additional property: It maintains a list of the map's keys in the order they were added to the map. This additional capability imposes a small amount of extra overhead on insertion and a larger amount of overhead on key removal, but absolutely no additional key lookup overhead. This class is conceptually similar to (though less feature-rich than) the java.util.LinkedHashMap class added in JDK 1.4.
-
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor and Description OrderedHashMap()Deprecated.Construct a new empty map with a default capacity and load factor.OrderedHashMap(int initialCapacity)Deprecated.Construct a new empty map with the specified initial capacity and a default load factor.OrderedHashMap(int initialCapacity, float loadFactor)Deprecated.Constructs a new, empty map with the specified initial capacity and the specified load factor.OrderedHashMap(java.util.Map<? extends K,? extends V> map)Deprecated.Constructs a new map with the same mappings as the given map.OrderedHashMap(OrderedHashMap<? extends K,? extends V> map)Deprecated.Constructs a new map with the same mappings as the given OrderedHashMap.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description voidclear()Deprecated.Remove all mappings from this map.java.lang.Objectclone()Deprecated.Returns a shallow copy of this instance.intgetKeysInInsertionOrder(java.util.List<? super K> list)Deprecated.Get the keys in the order they were added to this map.java.util.List<K>keysInInsertionOrder()Deprecated.Get the keys in the order they were added to this map.Vput(K key, V value)Deprecated.Associates the specified value with the specified key in this map.voidputAll(java.util.Map<? extends K,? extends V> map)Deprecated.Copies all of the mappings from a specified map to this one.voidputAll(OrderedHashMap<? extends K,? extends V> map)Deprecated.Copies all of the mappings from a specified map to this one.Vremove(java.lang.Object key)Deprecated.Removes the mapping for a key, if there is one.
-
-
-
Constructor Detail
-
OrderedHashMap
public OrderedHashMap()
Deprecated.Construct a new empty map with a default capacity and load factor.
-
OrderedHashMap
public OrderedHashMap(int initialCapacity)
Deprecated.Construct a new empty map with the specified initial capacity and a default load factor.- Parameters:
initialCapacity- the initial capacity
-
OrderedHashMap
public OrderedHashMap(int initialCapacity, float loadFactor)Deprecated.Constructs a new, empty map with the specified initial capacity and the specified load factor.- Parameters:
initialCapacity- the initial capacityloadFactor- the load factor
-
OrderedHashMap
public OrderedHashMap(java.util.Map<? extends K,? extends V> map)
Deprecated.Constructs a new map with the same mappings as the given map. The initial capacity and load factor is the same as for the parent HashMap class. Since there's no way of knowing in what order entries were made in the original map, the order imposed on them in this map is the order in which they are returned by the keySet() method.- Parameters:
map- the map whose mappings are to be copied- See Also:
OrderedHashMap(OrderedHashMap)
-
OrderedHashMap
public OrderedHashMap(OrderedHashMap<? extends K,? extends V> map)
Deprecated.Constructs a new map with the same mappings as the given OrderedHashMap. The initial capacity and load factor is the same as for the parent HashMap class. The insertion order of the keys is preserved.- Parameters:
map- the map whose mappings are to be copied
-
-
Method Detail
-
getKeysInInsertionOrder
public int getKeysInInsertionOrder(java.util.List<? super K> list)
Deprecated.Get the keys in the order they were added to this map.- Parameters:
list- the List to receive the keys- Returns:
- the number of keys added to the list
- See Also:
keysInInsertionOrder()
-
keysInInsertionOrder
public java.util.List<K> keysInInsertionOrder()
Deprecated.Get the keys in the order they were added to this map.- Returns:
- a new List containing the keys in insertion order
- See Also:
getKeysInInsertionOrder(java.util.List<? super K>)
-
clone
public java.lang.Object clone()
Deprecated.Returns a shallow copy of this instance. The keys and values themselves are not cloned.
-
clear
public void clear()
Deprecated.Remove all mappings from this map.
-
put
public V put(K key, V value)
Deprecated.Associates the specified value with the specified key in this map. If the key already has a value in this map, the existing value is replaced by the new value, and the old value is replaced. If the key already exists in the map, it is moved to the end of the key insertion order list.- Specified by:
putin interfacejava.util.Map<K,V>- Overrides:
putin classjava.util.HashMap<K,V>- Parameters:
key- the key with which the specified value is to be associatedvalue- the value to associate with the specified key- Returns:
- the previous value associated with the key, or null if (a) there was no previous value, or (b) the previous value was a null
-
putAll
public void putAll(java.util.Map<? extends K,? extends V> map)
Deprecated.Copies all of the mappings from a specified map to this one. These mappings replace any mappings that this map had for any of the keys in this map. Since there's no way of knowing in what order entries were made in the original map, they are appended to the key insertion order list in the order they are returned by the map's keySet() method.- Specified by:
putAllin interfacejava.util.Map<K,V>- Overrides:
putAllin classjava.util.HashMap<K,V>- Parameters:
map- the map whose mappings are to be copied- See Also:
putAll(OrderedHashMap)
-
putAll
public void putAll(OrderedHashMap<? extends K,? extends V> map)
Deprecated.Copies all of the mappings from a specified map to this one. These mappings replace any mappings that this map had for any of the keys in this map. The keys are appended to this map's key insertion order list in the order they were originally added to map.- Parameters:
map- the map whose mappings are to be copied- See Also:
putAll(OrderedHashMap),keysInInsertionOrder()
-
remove
public V remove(java.lang.Object key)
Deprecated.Removes the mapping for a key, if there is one. The key is also removed from the key insertion order list.
-
-
DMelt 3.0 © DataMelt by jWork.ORG