|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.utils.ArrayMap<K,V>
public class ArrayMap<K,V>
An ordered or unordered map of objects. This implementation uses arrays to store the keys and values, which means
getKey(Object, boolean)
does a comparison for each key in the map. This may be acceptable for small maps and has the
benefits that put(Object, Object)
and the keys and values can be accessed by index, which makes iteration fast. Like
Array
, if ordered is false, this class avoids a memory copy when removing elements (the last element is moved to the
removed element's position).
Field Summary | |
---|---|
K[] |
keys
|
boolean |
ordered
|
int |
size
|
V[] |
values
|
Constructor Summary | |
---|---|
ArrayMap()
Creates an ordered map with a capacity of 16. |
|
ArrayMap(ArrayMap array)
Creates a new map containing the elements in the specified map. |
|
ArrayMap(boolean ordered,
int capacity)
|
|
ArrayMap(boolean ordered,
int capacity,
java.lang.Class<K> keyArrayType,
java.lang.Class<V> valueArrayType)
Creates a new map with keys and values of the specified type. |
|
ArrayMap(java.lang.Class<K> keyArrayType,
java.lang.Class<V> valueArrayType)
Creates an ordered map with keys and values of the specified type and a capacity of 16. |
|
ArrayMap(int capacity)
Creates an ordered map with the specified capacity. |
Method Summary | |
---|---|
void |
addAll(ArrayMap map)
|
void |
addAll(ArrayMap map,
int offset,
int length)
|
void |
clear()
|
boolean |
containsKey(K key,
boolean identity)
|
boolean |
containsValue(V value,
boolean identity)
|
void |
ensureCapacity(int additionalCapacity)
Increases the size of the backing arrays to acommodate the specified number of additional entries. |
V |
get(K key)
Returns the value for the specified key. |
V |
get(K key,
boolean identity)
Returns the value for the specified key. |
K |
getKey(V value,
boolean identity)
Returns the key for the specified value. |
K |
getKeyAt(int index)
|
V |
getValueAt(int index)
|
int |
indexOfKey(K key,
boolean identity)
|
int |
indexOfValue(V value,
boolean identity)
|
void |
insert(int index,
K key,
V value)
|
K |
peekKey()
Returns the last key. |
V |
peekValue()
Returns the last value. |
void |
put(K key,
V value)
|
void |
removeIndex(int index)
Removes and returns the key/values pair at the specified index. |
V |
removeKey(K key,
boolean identity)
|
boolean |
removeValue(V value,
boolean identity)
|
protected void |
resize(int newSize)
|
void |
reverse()
|
void |
setKey(int index,
K key)
|
void |
setValue(int index,
V value)
|
void |
shrink()
Reduces the size of the backing arrays to the size of the actual number of entries. |
void |
shuffle()
|
java.lang.String |
toString()
|
void |
truncate(int newSize)
Reduces the size of the arrays to the specified size. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public K[] keys
public V[] values
public int size
public boolean ordered
Constructor Detail |
---|
public ArrayMap()
public ArrayMap(int capacity)
public ArrayMap(boolean ordered, int capacity)
ordered
- If false, methods that remove elements may change the order of other elements in the arrays, which avoids a
memory copy.capacity
- Any elements added beyond this will cause the backing arrays to be grown.public ArrayMap(boolean ordered, int capacity, java.lang.Class<K> keyArrayType, java.lang.Class<V> valueArrayType)
keys
and values
of the specified type.
ordered
- If false, methods that remove elements may change the order of other elements in the arrays, which avoids a
memory copy.capacity
- Any elements added beyond this will cause the backing arrays to be grown.public ArrayMap(java.lang.Class<K> keyArrayType, java.lang.Class<V> valueArrayType)
keys
and values
of the specified type and a capacity of 16.
public ArrayMap(ArrayMap array)
Method Detail |
---|
public void put(K key, V value)
public void addAll(ArrayMap map)
public void addAll(ArrayMap map, int offset, int length)
public V get(K key)
public V get(K key, boolean identity)
identity
- If true, == comparison will be used. If false, .equals() comaparison will be used.public K getKey(V value, boolean identity)
identity
- If true, == comparison will be used. If false, .equals() comaparison will be used.public K getKeyAt(int index)
public V getValueAt(int index)
public void setKey(int index, K key)
public void setValue(int index, V value)
public void insert(int index, K key, V value)
public boolean containsKey(K key, boolean identity)
identity
- If true, == comparison will be used. If false, .equals() comaparison will be used.public boolean containsValue(V value, boolean identity)
identity
- If true, == comparison will be used. If false, .equals() comaparison will be used.public int indexOfKey(K key, boolean identity)
public int indexOfValue(V value, boolean identity)
public V removeKey(K key, boolean identity)
public boolean removeValue(V value, boolean identity)
public void removeIndex(int index)
public K peekKey()
public V peekValue()
public void clear()
public void shrink()
public void ensureCapacity(int additionalCapacity)
protected void resize(int newSize)
public void reverse()
public void shuffle()
public void truncate(int newSize)
public java.lang.String toString()
toString
in class java.lang.Object
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |