V
- the type of value contained in this map.java.util.Map<java.lang.Integer,V>
public final class IndexMap<V>
extends java.lang.Object
implements java.util.Map<java.lang.Integer,V>
This should not be used as a general int-keyed map as the backing array will take space up to the largest key. Use this when you have an expected maximum index (but not necessarily known or constant) that you need to sporadically fill mappings up to.
Constructor | Description |
---|---|
IndexMap() |
Creates a new map with the default initial capacity of 10 and
default reservoir size of 30.
|
IndexMap(int initialCapacity) |
Creates a new map with the given initial capacity and default
reservoir size of 30.
|
IndexMap(int initialCapacity,
int reservoirSize) |
Creates a new map with the given initial capacity and reservoir size.
|
Modifier and Type | Method | Description |
---|---|---|
void |
clear() |
|
boolean |
containsKey(int key) |
|
boolean |
containsKey(java.lang.Object key) |
|
boolean |
containsValue(java.lang.Object value) |
|
java.util.Set<java.util.Map.Entry<java.lang.Integer,V>> |
entrySet() |
Do NOT use this.
|
V |
get(int key) |
|
V |
get(java.lang.Object key) |
|
boolean |
isEmpty() |
|
java.util.Set<java.lang.Integer> |
keySet() |
|
V |
put(int key,
V value) |
|
V |
put(java.lang.Integer key,
V value) |
|
void |
putAll(java.util.Map<? extends java.lang.Integer,? extends V> m) |
|
V |
remove(int key) |
|
V |
remove(java.lang.Object key) |
|
int |
size() |
|
java.util.Collection<V> |
values() |
public IndexMap()
public IndexMap(int initialCapacity)
initialCapacity
- the base capacity to start with.public IndexMap(int initialCapacity, int reservoirSize)
initialCapacity
- the base capacity to start with.reservoirSize
- the amount of padding to be included in the backing array.public int size()
size
in interface java.util.Map<java.lang.Integer,V>
public boolean isEmpty()
isEmpty
in interface java.util.Map<java.lang.Integer,V>
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<java.lang.Integer,V>
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<java.lang.Integer,V>
public V get(java.lang.Object key)
get
in interface java.util.Map<java.lang.Integer,V>
public V put(java.lang.Integer key, V value)
put
in interface java.util.Map<java.lang.Integer,V>
public V remove(java.lang.Object key)
remove
in interface java.util.Map<java.lang.Integer,V>
public void putAll(java.util.Map<? extends java.lang.Integer,? extends V> m)
putAll
in interface java.util.Map<java.lang.Integer,V>
public void clear()
clear
in interface java.util.Map<java.lang.Integer,V>
public java.util.Set<java.lang.Integer> keySet()
keySet
in interface java.util.Map<java.lang.Integer,V>
public java.util.Collection<V> values()
values
in interface java.util.Map<java.lang.Integer,V>
public java.util.Set<java.util.Map.Entry<java.lang.Integer,V>> entrySet()
entrySet
in interface java.util.Map<java.lang.Integer,V>
public boolean containsKey(int key)
public V get(int key)
public V remove(int key)