public class OrderedHashMap<K,V>
extends java.util.HashMap<K,V>
implements java.lang.Cloneable, java.io.Serializable
An 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.
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.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Deprecated.
Remove all mappings from this map.
|
java.lang.Object |
clone()
Deprecated.
Returns a shallow copy of this instance.
|
int |
getKeysInInsertionOrder(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.
|
V |
put(K key,
V value)
Deprecated.
Associates the specified value with the specified key in this map.
|
void |
putAll(java.util.Map<? extends K,? extends V> map)
Deprecated.
Copies all of the mappings from a specified map to this one.
|
void |
putAll(OrderedHashMap<? extends K,? extends V> map)
Deprecated.
Copies all of the mappings from a specified map to this one.
|
V |
remove(java.lang.Object key)
Deprecated.
Removes the mapping for a key, if there is one.
|
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putIfAbsent, remove, replace, replace, replaceAll, size, values
public OrderedHashMap()
public OrderedHashMap(int initialCapacity)
initialCapacity
- the initial capacitypublic OrderedHashMap(int initialCapacity, float loadFactor)
initialCapacity
- the initial capacityloadFactor
- the load factorpublic OrderedHashMap(java.util.Map<? extends K,? extends V> map)
map
- the map whose mappings are to be copiedOrderedHashMap(OrderedHashMap)
public OrderedHashMap(OrderedHashMap<? extends K,? extends V> map)
map
- the map whose mappings are to be copiedpublic int getKeysInInsertionOrder(java.util.List<? super K> list)
list
- the List to receive the keyskeysInInsertionOrder()
public java.util.List<K> keysInInsertionOrder()
getKeysInInsertionOrder(java.util.List<? super K>)
public java.lang.Object clone()
public void clear()
public V put(K key, V value)
put
in interface java.util.Map<K,V>
put
in class java.util.HashMap<K,V>
key
- the key with which the specified value is to be associatedvalue
- the value to associate with the specified keypublic void putAll(java.util.Map<? extends K,? extends V> map)
putAll
in interface java.util.Map<K,V>
putAll
in class java.util.HashMap<K,V>
map
- the map whose mappings are to be copiedputAll(OrderedHashMap)
public void putAll(OrderedHashMap<? extends K,? extends V> map)
map
- the map whose mappings are to be copiedputAll(OrderedHashMap)
,
keysInInsertionOrder()
public V remove(java.lang.Object key)