gets do a comparison for each key in the map. This is slower than a typical hash map
implementation, but may be acceptable for small maps and has the benefits that 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).
| Modifier and Type | Class and Description |
|---|---|
| public static class | |
| public static class | |
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| private transient ArrayMap. | |
| private transient ArrayMap. | |
| public K[] | |
| private transient ArrayMap. | |
| private transient ArrayMap. | |
| public boolean | |
| public int | |
| public V[] | |
| private transient ArrayMap. | |
| private transient ArrayMap. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | ArrayMap(boolean
If false, methods that remove elements may change the order of other elements in the arrays, which avoids a
memory copy. ordered, int Any elements added beyond this will cause the backing arrays to be grown. capacity)
|
| public | ArrayMap(boolean
If false, methods that remove elements may change the order of other elements in the arrays, which avoids a
memory copy. ordered, int Any elements added beyond this will cause the backing arrays to be grown. capacity, ArraySupplier<K[]> keyArraySupplier, ArraySupplier<V[]> valueArraySupplier)Creates a new map with |
| public | ArrayMap(ArraySupplier<K[]> keyArraySupplier, ArraySupplier<V[]> valueArraySupplier)
Creates an ordered map with |
| public | ArrayMap(boolean
If false, methods that remove elements may change the order of other elements in the arrays, which avoids a
memory copy. ordered, int Any elements added beyond this will cause the backing arrays to be grown. capacity, Class<T> keyArrayType, Class<T> valueArrayType)
Deprecated
Use
ArrayMap#ArrayMap(boolean, int, ArraySupplier, ArraySupplier) instead
Creates a new map with |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear(int maximumCapacity)
Clears the map and reduces the size of the backing arrays to be the specified capacity if they are larger. |
| public void | |
| public boolean | |
| public boolean | containsValue(V value, boolean
If true, == comparison will be used. If false, .equals() comparison will be used. identity)
|
| public void | ensureCapacity(int additionalCapacity)
Increases the size of the backing arrays to accommodate the specified number of additional entries. |
| public ArrayMap. | |
| public boolean | equals(Object obj)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public boolean | |
| public K | |
| public V | |
| public 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. |
| public 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. |
| public K | getKey(V value, boolean
If true, == comparison will be used. If false, .equals() comparison will be used. identity)Returns the key for the specified value. |
| public K | |
| public V | |
| public int | |
| public int | |
| public int | |
| public void | |
| public boolean | |
| public Iterator | |
| public ArrayMap. | |
| public boolean | |
| public K | |
| public V | |
| public int | |
| public int | |
| public void | |
| public void | |
| public V | |
| public void | |
| public V | |
| public boolean | |
| protected void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public String | |
| public void | |
| public ArrayMap. |
| entries1 | back to summary |
|---|---|
| private transient ArrayMap. | |
| entries2 | back to summary |
|---|---|
| private transient ArrayMap. | |
| keys | back to summary |
|---|---|
| public K[] keys | |
| keys1 | back to summary |
|---|---|
| private transient ArrayMap. | |
| keys2 | back to summary |
|---|---|
| private transient ArrayMap. | |
| ordered | back to summary |
|---|---|
| public boolean ordered | |
| size | back to summary |
|---|---|
| public int size | |
| values | back to summary |
|---|---|
| public V[] values | |
| values1 | back to summary |
|---|---|
| private transient ArrayMap. | |
| values2 | back to summary |
|---|---|
| private transient ArrayMap. | |
| ArrayMap | back to summary |
|---|---|
| public ArrayMap() Creates an ordered map with a capacity of 16. | |
| ArrayMap | back to summary |
|---|---|
| public ArrayMap(int capacity) Creates an ordered map with the specified capacity. | |
| ArrayMap | back to summary |
|---|---|
public ArrayMap(boolean ordered, int capacity)
| |
| ArrayMap | back to summary |
|---|---|
| public ArrayMap(boolean ordered, int capacity, ArraySupplier<K[]> keyArraySupplier, ArraySupplier<V[]> valueArraySupplier) Creates a new map with
| |
| ArrayMap | back to summary |
|---|---|
| public ArrayMap(ArraySupplier<K[]> keyArraySupplier, ArraySupplier<V[]> valueArraySupplier) Creates an ordered map with | |
| ArrayMap | back to summary |
|---|---|
| public ArrayMap(boolean ordered, int capacity, Class<T> keyArrayType, Class<T> valueArrayType)
Deprecated Use Creates a new map with
| |
| ArrayMap | back to summary |
|---|---|
| public ArrayMap(Class<T> keyArrayType, Class<T> valueArrayType)
Deprecated Use Creates an ordered map with
| |
| ArrayMap | back to summary |
|---|---|
| public ArrayMap(ArrayMap<K, V> array) Creates a new map containing the elements in the specified map. The new map will have the same type of backing arrays and will be ordered if the specified map is ordered. The capacity is set to the number of elements, so any subsequent elements added will cause the backing arrays to be grown. | |
| clear | back to summary |
|---|---|
| public void clear(int maximumCapacity) Clears the map and reduces the size of the backing arrays to be the specified capacity if they are larger. | |
| clear | back to summary |
|---|---|
| public void clear() | |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(K key) | |
| containsValue | back to summary |
|---|---|
public boolean containsValue(V value, boolean identity)
| |
| ensureCapacity | back to summary |
|---|---|
| public void ensureCapacity(int additionalCapacity) Increases the size of the backing arrays to accommodate the specified number of additional entries. Useful before adding many entries to avoid multiple backing array resizes. | |
| entries | back to summary |
|---|---|
| public ArrayMap. Returns an iterator for the entries in the map. Remove is supported.
If
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| equalsIdentity | back to summary |
|---|---|
| public boolean equalsIdentity(Object obj) Uses == for comparison of each value. | |
| firstKey | back to summary |
|---|---|
| public K firstKey() | |
| firstValue | back to summary |
|---|---|
| public V firstValue() | |
| get | back to summary |
|---|---|
| public 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. Note this does a .equals() comparison of each key in reverse order until the specified key is found.
| |
| get | back to summary |
|---|---|
| public 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. Note this does a .equals() comparison of each key in reverse order until the specified key is found.
| |
| getKey | back to summary |
|---|---|
| public K getKey(V value, boolean identity) Returns the key for the specified value. Note this does a comparison of each value in reverse order until the specified value is found.
| |
| getKeyAt | back to summary |
|---|---|
| public K getKeyAt(int index) | |
| getValueAt | back to summary |
|---|---|
| public V getValueAt(int index) | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| indexOfKey | back to summary |
|---|---|
| public int indexOfKey(K key) | |
| indexOfValue | back to summary |
|---|---|
| public int indexOfValue(V value, boolean identity) | |
| insert | back to summary |
|---|---|
| public void insert(int index, K key, V value) | |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Returns true if the map is empty. | |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over elements of type | |
| keys | back to summary |
|---|---|
| public ArrayMap. Returns an iterator for the keys in the map. Remove is supported.
If
| |
| notEmpty | back to summary |
|---|---|
| public boolean notEmpty() Returns true if the map has one or more items. | |
| peekKey | back to summary |
|---|---|
| public K peekKey() Returns the last key. | |
| peekValue | back to summary |
|---|---|
| public V peekValue() Returns the last value. | |
| put | back to summary |
|---|---|
| public int put(K key, V value) | |
| put | back to summary |
|---|---|
| public int put(K key, V value, int index) | |
| putAll | back to summary |
|---|---|
| public void putAll(ArrayMap<? extends K, ? extends V> map) | |
| putAll | back to summary |
|---|---|
| public void putAll(ArrayMap<? extends K, ? extends V> map, int offset, int length) | |
| putMissing | back to summary |
|---|---|
public V putMissing(K key, V value)
| |
| removeIndex | back to summary |
|---|---|
| public void removeIndex(int index) Removes and returns the key/values pair at the specified index. | |
| removeKey | back to summary |
|---|---|
public V removeKey(K key)
| |
| removeValue | back to summary |
|---|---|
| public boolean removeValue(V value, boolean identity) | |
| resize | back to summary |
|---|---|
| protected void resize(int newSize) | |
| reverse | back to summary |
|---|---|
| public void reverse() | |
| setKey | back to summary |
|---|---|
| public void setKey(int index, K key) | |
| setValue | back to summary |
|---|---|
| public void setValue(int index, V value) | |
| shrink | back to summary |
|---|---|
| public void shrink() Reduces the size of the backing arrays to the size of the actual number of entries. This is useful to release memory when many items have been removed, or if it is known that more entries will not be added. | |
| shuffle | back to summary |
|---|---|
| public void shuffle() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| truncate | back to summary |
|---|---|
| public void truncate(int newSize) Reduces the size of the arrays to the specified size. If the arrays are already smaller than the specified size, no action is taken. | |
| values | back to summary |
|---|---|
| public ArrayMap. Returns an iterator for the values in the map. Remove is supported.
If
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv ObjectMap. | |
| pack-priv int | |
| private final ArrayMap | |
| pack-priv boolean |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public Iterator | |
| public ObjectMap. | next()
Implements java. Note the same entry instance is returned each time this method is called. |
| public void | remove()
Overrides default java. Removes from the underlying collection the last element returned by this iterator (optional operation). |
| public void |
| entry | back to summary |
|---|---|
| pack-priv ObjectMap. | |
| index | back to summary |
|---|---|
| pack-priv int index | |
| map | back to summary |
|---|---|
| private final ArrayMap<K, V> map | |
| valid | back to summary |
|---|---|
| pack-priv boolean valid | |
| Entries | back to summary |
|---|---|
| public Entries(ArrayMap<K, V> map) | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns | |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over elements of type | |
| next | back to summary |
|---|---|
| public ObjectMap. Implements java. Note the same entry instance is returned each time this method is called. | |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the | |
| reset | back to summary |
|---|---|
| public void reset() | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int | |
| private final ArrayMap | |
| pack-priv boolean |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public Iterator | |
| public K | |
| public void | remove()
Overrides default java. Removes from the underlying collection the last element returned by this iterator (optional operation). |
| public void | |
| public Array | |
| public Array |
| index | back to summary |
|---|---|
| pack-priv int index | |
| map | back to summary |
|---|---|
| private final ArrayMap<K, Object> map | |
| valid | back to summary |
|---|---|
| pack-priv boolean valid | |
| Keys | back to summary |
|---|---|
| public Keys(ArrayMap<K, Object> map) | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns | |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over elements of type | |
| next | back to summary |
|---|---|
| public K next() Implements java. Doc from java. Returns the next element in the iteration. | |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the | |
| reset | back to summary |
|---|---|
| public void reset() | |
| toArray | back to summary |
|---|---|
| public Array | |
| toArray | back to summary |
|---|---|
| public Array | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int | |
| private final ArrayMap | |
| pack-priv boolean |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public Iterator | |
| public V | |
| public void | remove()
Overrides default java. Removes from the underlying collection the last element returned by this iterator (optional operation). |
| public void | |
| public Array | |
| public Array |
| index | back to summary |
|---|---|
| pack-priv int index | |
| map | back to summary |
|---|---|
| private final ArrayMap<Object, V> map | |
| valid | back to summary |
|---|---|
| pack-priv boolean valid | |
| Values | back to summary |
|---|---|
| public Values(ArrayMap<Object, V> map) | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns | |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over elements of type | |
| next | back to summary |
|---|---|
| public V next() Implements java. Doc from java. Returns the next element in the iteration. | |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the | |
| reset | back to summary |
|---|---|
| public void reset() | |
| toArray | back to summary |
|---|---|
| public Array | |
| toArray | back to summary |
|---|---|
| public Array | |