com.badlogic.gdx.utils
Class OrderedMap<K,V>

java.lang.Object
  extended by com.badlogic.gdx.utils.ObjectMap<K,V>
      extended by com.badlogic.gdx.utils.OrderedMap<K,V>

public class OrderedMap<K,V>
extends ObjectMap<K,V>

An ObjectMap that also stores keys in an Array using the insertion order. There is some additional overhead for put and remove. Iteration over the entries(), keys(), and values() is ordered. Keys can also be accessed and the order changed using orderedKeys().

Author:
Nathan Sweet

Nested Class Summary
 
Nested classes/interfaces inherited from class com.badlogic.gdx.utils.ObjectMap
ObjectMap.Entries<K,V>, ObjectMap.Entry<K,V>, ObjectMap.Keys<K>, ObjectMap.Values<V>
 
Field Summary
 
Fields inherited from class com.badlogic.gdx.utils.ObjectMap
size
 
Constructor Summary
OrderedMap()
           
OrderedMap(int initialCapacity)
           
OrderedMap(int initialCapacity, float loadFactor)
           
 
Method Summary
 void clear()
           
 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.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)
           
 String toString()
           
 ObjectMap.Values<V> values()
          Returns an iterator for the values in the map.
 
Methods inherited from class com.badlogic.gdx.utils.ObjectMap
containsKey, containsValue, ensureCapacity, findKey, get, get, putAll, shrink
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OrderedMap

public OrderedMap()

OrderedMap

public OrderedMap(int initialCapacity)

OrderedMap

public OrderedMap(int initialCapacity,
                  float loadFactor)
Method Detail

put

public V put(K key,
             V value)
Description copied from class: ObjectMap
Returns the old value associated with the specified key, or null.

Overrides:
put in class ObjectMap<K,V>

remove

public V remove(K key)
Overrides:
remove in class ObjectMap<K,V>

clear

public void clear(int maximumCapacity)
Description copied from class: ObjectMap
Clears the map and reduces the size of the backing arrays to be the specified capacity if they are larger.

Overrides:
clear in class ObjectMap<K,V>

clear

public void clear()
Overrides:
clear in class ObjectMap<K,V>

orderedKeys

public Array<K> orderedKeys()

entries

public ObjectMap.Entries<K,V> entries()
Description copied from class: ObjectMap
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 the ObjectMap.Entries constructor for nested or multithreaded iteration.

Overrides:
entries in class ObjectMap<K,V>

keys

public ObjectMap.Keys<K> keys()
Description copied from class: ObjectMap
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 the ObjectMap.Entries constructor for nested or multithreaded iteration.

Overrides:
keys in class ObjectMap<K,V>

values

public ObjectMap.Values<V> values()
Description copied from class: ObjectMap
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 the ObjectMap.Entries constructor for nested or multithreaded iteration.

Overrides:
values in class ObjectMap<K,V>

toString

public String toString()
Overrides:
toString in class ObjectMap<K,V>


Copyright © 2013. All Rights Reserved.