public class OrderedMap<K,V> extends ObjectMap<K,V>
ObjectMap
that also stores keys in an Array
using the insertion order. Iteration over the
entries()
, keys()
, and values()
is ordered and faster than an unordered map. Keys can also be
accessed and the order changed using orderedKeys()
. There is some additional overhead for put and remove. When used
for faster iteration versus ObjectMap and the order does not actually matter, copying during remove can be greatly reduced by
setting Array.ordered
to false for orderedKeys()
.Modifier and Type | Class and Description |
---|---|
static class |
OrderedMap.OrderedMapEntries<K,V> |
static class |
OrderedMap.OrderedMapKeys<K> |
static class |
OrderedMap.OrderedMapValues<V> |
ObjectMap.Entries<K,V>, ObjectMap.Entry<K,V>, ObjectMap.Keys<K>, ObjectMap.Values<V>
Constructor and Description |
---|
OrderedMap() |
OrderedMap(int initialCapacity) |
OrderedMap(int initialCapacity,
float loadFactor) |
OrderedMap(OrderedMap<? extends K,? extends V> map) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the map, leaving the backing arrays at the current capacity.
|
void |
clear(int maximumCapacity)
Clears the map and reduces the size of the backing arrays to be the specified capacity, if they are larger.
|
ObjectMap.Entries<K,V> |
entries()
Returns an iterator for the entries in the map.
|
ObjectMap.Entries<K,V> |
iterator() |
ObjectMap.Keys<K> |
keys()
Returns an iterator for the keys in the map.
|
Array<K> |
orderedKeys() |
V |
put(K key,
V value)
Returns the old value associated with the specified key, or null.
|
V |
remove(K key)
Returns the value associated with the key, or null.
|
V |
removeIndex(int index) |
String |
toString() |
ObjectMap.Values<V> |
values()
Returns an iterator for the values in the map.
|
containsKey, containsValue, ensureCapacity, equals, findKey, get, get, hashCode, isEmpty, putAll, shrink, toString
forEach, spliterator
public OrderedMap()
public OrderedMap(int initialCapacity)
public OrderedMap(int initialCapacity, float loadFactor)
public OrderedMap(OrderedMap<? extends K,? extends V> map)
public V put(K key, V value)
ObjectMap
public V remove(K key)
ObjectMap
public V removeIndex(int index)
public void clear(int maximumCapacity)
ObjectMap
public void clear()
ObjectMap
ObjectMap.clear(int)
can be used to reduce the capacity.public ObjectMap.Entries<K,V> iterator()
public ObjectMap.Entries<K,V> entries()
OrderedMap.OrderedMapEntries
constructor for nested or multithreaded iteration.public ObjectMap.Values<V> values()
OrderedMap.OrderedMapValues
constructor for nested or multithreaded iteration.public ObjectMap.Keys<K> keys()
OrderedMap.OrderedMapKeys
constructor for nested or multithreaded iteration.Copyright © 2018. All rights reserved.