Package arc.struct
Class OrderedMap<K,V>
java.lang.Object
arc.struct.ObjectMap<K,V>
arc.struct.OrderedMap<K,V>
- All Implemented Interfaces:
Iterable<ObjectMap.Entry<K,V>>
An
ObjectMap that also stores keys in an Seq 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 Seq.ordered to false for orderedKeys().-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classNested classes/interfaces inherited from class arc.struct.ObjectMap
ObjectMap.Entries<K,V>, ObjectMap.Entry<K, V>, ObjectMap.Keys<K>, ObjectMap.Values<V> -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionOrderedMap(int initialCapacity) OrderedMap(int initialCapacity, float loadFactor) OrderedMap(OrderedMap<? extends K, ? extends V> map) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the map, leaving the backing arrays at the current capacity.voidclear(int maximumCapacity) Clears the map and reduces the size of the backing arrays to be the specified capacity, if they are larger.entries()Returns an iterator for the entries in the map.iterator()keys()Returns an iterator for the keys in the map.static <K,V> OrderedMap<K, V> Returns the old value associated with the specified key, or null.Returns the value associated with the key, or null.removeIndex(int index) toString()values()Returns an iterator for the values in the map.Methods inherited from class arc.struct.ObjectMap
containsKey, containsValue, copy, each, ensureCapacity, equals, findKey, get, get, get, getNull, getThrow, hashCode, isEmpty, merge, putAll, putAll, set, shrink, toString, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
OrderedMap
public OrderedMap() -
OrderedMap
public OrderedMap(int initialCapacity) -
OrderedMap
public OrderedMap(int initialCapacity, float loadFactor) -
OrderedMap
-
-
Method Details
-
of
-
put
Description copied from class:ObjectMapReturns the old value associated with the specified key, or null. -
remove
Description copied from class:ObjectMapReturns the value associated with the key, or null. -
removeIndex
-
clear
public void clear(int maximumCapacity) Description copied from class:ObjectMapClears the map and reduces the size of the backing arrays to be the specified capacity, if they are larger. The reduction is done by allocating new arrays, though for large arrays this can be faster than clearing the existing array. -
clear
public void clear()Description copied from class:ObjectMapClears the map, leaving the backing arrays at the current capacity. When the capacity is high and the population is low, iteration can be unnecessarily slow.ObjectMap.clear(int)can be used to reduce the capacity. -
orderedKeys
-
iterator
-
entries
Returns an iterator for the entries in the map. Remove is supported. Note that the same iterator instance is returned each time this method is called. Use theOrderedMap.OrderedMapEntriesconstructor for nested or multithreaded iteration. -
values
Returns an iterator for the values in the map. Remove is supported. Note that the same iterator instance is returned each time this method is called. Use theOrderedMap.OrderedMapValuesconstructor for nested or multithreaded iteration. -
keys
Returns an iterator for the keys in the map. Remove is supported. Note that the same iterator instance is returned each time this method is called. Use theOrderedMap.OrderedMapKeysconstructor for nested or multithreaded iteration. -
toString
-