public class ConcurrentArrayMap<K,V> extends org.mini2Dx.gdx.utils.ArrayMap<K,V> implements ConcurrentCollection
Modifier and Type | Field and Description |
---|---|
protected ReadWriteLock |
lock |
Constructor and Description |
---|
ConcurrentArrayMap()
Creates an ordered map with a capacity of 16.
|
ConcurrentArrayMap(org.mini2Dx.gdx.utils.ArrayMap array)
Creates a new map containing the elements in the specified map.
|
ConcurrentArrayMap(boolean ordered,
int capacity) |
ConcurrentArrayMap(boolean ordered,
int capacity,
java.lang.Class keyArrayType,
java.lang.Class valueArrayType)
|
ConcurrentArrayMap(java.lang.Class keyArrayType,
java.lang.Class valueArrayType)
|
ConcurrentArrayMap(int capacity)
Creates an ordered map with the specified capacity.
|
Modifier and Type | Method and Description |
---|---|
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.
|
boolean |
containsKey(K key) |
boolean |
containsValue(V value,
boolean identity) |
void |
ensureCapacity(int additionalCapacity)
Increases the size of the backing arrays to accommodate the specified number of additional entries.
|
org.mini2Dx.gdx.utils.ArrayMap.Entries<K,V> |
entries()
Returns an iterator for the entries in the map.
|
boolean |
equals(java.lang.Object obj) |
boolean |
equalsIdentity(java.lang.Object obj)
Uses == for comparison of each value.
|
K |
firstKey() |
V |
firstValue() |
V |
get(K key)
Returns the value (which may be null) for the specified key, or null if the key is not in the map.
|
V |
get(K key,
V defaultValue)
Returns the value (which may be null) for the specified key, or the default value if the key is not in the map.
|
K |
getKey(V value,
boolean identity)
Returns the key for the specified value.
|
K |
getKeyAt(int index) |
ReadWriteLock |
getLock()
Returns the collection's
ReadWriteLock |
V |
getValueAt(int index) |
int |
hashCode() |
int |
indexOfKey(K key) |
int |
indexOfValue(V value,
boolean identity) |
void |
insert(int index,
K key,
V value) |
boolean |
isEmpty()
Returns true if the map is empty.
|
org.mini2Dx.gdx.utils.ArrayMap.Keys<K> |
keys()
Returns an iterator for the keys in the map.
|
boolean |
notEmpty()
Returns true if the map has one or more items.
|
K |
peekKey()
Returns the last key.
|
V |
peekValue()
Returns the last value.
|
int |
put(K key,
V value) |
int |
put(K key,
V value,
int index) |
void |
putAll(org.mini2Dx.gdx.utils.ArrayMap<? extends K,? extends V> map,
int offset,
int length) |
void |
removeIndex(int index)
Removes and returns the key/values pair at the specified index.
|
V |
removeKey(K key) |
boolean |
removeValue(V value,
boolean identity) |
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.
|
org.mini2Dx.gdx.utils.ArrayMap.Values<V> |
values()
Returns an iterator for the values in the map.
|
protected ReadWriteLock lock
public ConcurrentArrayMap()
public ConcurrentArrayMap(int capacity)
capacity
- public ConcurrentArrayMap(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 ConcurrentArrayMap(boolean ordered, int capacity, java.lang.Class keyArrayType, java.lang.Class valueArrayType)
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.keyArrayType
- valueArrayType
- public ConcurrentArrayMap(java.lang.Class keyArrayType, java.lang.Class valueArrayType)
keyArrayType
- valueArrayType
- public ConcurrentArrayMap(org.mini2Dx.gdx.utils.ArrayMap array)
array
- public void putAll(org.mini2Dx.gdx.utils.ArrayMap<? extends K,? extends V> map, int offset, int length)
public V get(K key)
public V get(K key, V defaultValue)
public K getKey(V value, boolean identity)
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 boolean containsKey(K key)
public boolean containsValue(V value, boolean identity)
public int indexOfKey(K key)
public int indexOfValue(V value, boolean identity)
public void removeIndex(int index)
public boolean notEmpty()
public boolean isEmpty()
public K peekKey()
public V peekValue()
public void clear(int maximumCapacity)
public void shrink()
public void ensureCapacity(int additionalCapacity)
public void truncate(int newSize)
public boolean removeValue(V value, boolean identity)
public boolean equals(java.lang.Object obj)
public boolean equalsIdentity(java.lang.Object obj)
public java.lang.String toString()
public org.mini2Dx.gdx.utils.ArrayMap.Entries<K,V> entries()
If Collections.allocateIterators
is false, the same iterator instance is returned each time this method is called. Use the
Entries
constructor for nested or multithreaded iteration.
public org.mini2Dx.gdx.utils.ArrayMap.Values<V> values()
If Collections.allocateIterators
is false, the same iterator instance is returned each time this method is called. Use the
Entries
constructor for nested or multithreaded iteration.
public org.mini2Dx.gdx.utils.ArrayMap.Keys<K> keys()
If Collections.allocateIterators
is false, the same iterator instance is returned each time this method is called. Use the
Entries
constructor for nested or multithreaded iteration.
public ReadWriteLock getLock()
ConcurrentCollection
ReadWriteLock
getLock
in interface ConcurrentCollection
ReadWriteLock