K - the key typeV - the value typepublic class ListMap<K,V> extends Object implements Map<K,V>, Serializable
Map that uses a List to hold the entries, retaining the
order of insertion. This class is useful when the order of insertion of entries is
significant, but it suffers from serious performance degradation when the numbers of entries
exceeds a handful.| Modifier and Type | Class and Description |
|---|---|
static class |
ListMap.Entry<KK,VV>
Inner class to represent a key-value pair in the
ListMap. |
| Modifier and Type | Field and Description |
|---|---|
protected List<ListMap.Entry<K,V>> |
list |
| Constructor and Description |
|---|
ListMap()
Construct an empty
ListMap. |
ListMap(int capacity)
Construct an empty
ListMap with a specified initial capacity. |
ListMap(Map<? extends K,? extends V> m)
Construct a
ListMap with the contents of another Map. |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Remove all members from this
ListMap. |
boolean |
containsKey(Object key)
Test whether the
ListMap contains a specified key. |
boolean |
containsValue(Object value)
Test whether the
ListMap contains the specified value. |
Set<Map.Entry<K,V>> |
entrySet()
Get a
Set of the key-value pairs in use in the ListMap. |
boolean |
equals(Object other)
Compare this
ListMap with another object for equality. |
protected int |
findIndex(Object key)
Find the index for the specified key.
|
V |
get(Object key)
Get a value from the
ListMap. |
ListMap.Entry<K,V> |
getEntry(int index)
Get an
ListMap.Entry by index. |
int |
hashCode()
Get the hash code for this
ListMap. |
boolean |
isEmpty()
Test whether the
ListMapis empty. |
Set<K> |
keySet()
Get a
Set representing the keys in use in the ListMap. |
V |
put(K key,
V value)
Store a value in the
ListMap with the specified key. |
void |
putAll(Map<? extends K,? extends V> m)
Add all the members of another
Map to this ListMap. |
V |
remove(Object key)
Remove the specified key-value mapping from the
ListMap. |
int |
size()
Get the number of values in the
ListMap. |
String |
toString()
Convert the map to
String (usually for diagnostic purposes). |
Collection<V> |
values()
Get a
Collection of the values in the ListMap. |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllprotected List<ListMap.Entry<K,V>> list
public ListMap()
ListMap.public ListMap(int capacity)
ListMap with a specified initial capacity.capacity - the initial capacitypublic V get(Object key)
ListMap.get in interface Map<K,V>key - the key of the valuenull if not foundMap.get(Object)public boolean containsKey(Object key)
ListMap contains a specified key.containsKey in interface Map<K,V>key - the key to test fortrue if the key is foundMap.containsKey(Object)public V put(K key, V value)
ListMap with the specified key.put in interface Map<K,V>key - the keyvalue - the valuenull if no previous
valueMap.put(Object, Object)public V remove(Object key)
ListMap.remove in interface Map<K,V>key - the keynull if key not usedMap.remove(Object)public int size()
ListMap.size in interface Map<K,V>Map.size()public boolean isEmpty()
ListMapis empty.isEmpty in interface Map<K,V>true if the ListMap is emptyMap.isEmpty()public boolean containsValue(Object value)
ListMap contains the specified value.containsValue in interface Map<K,V>value - the valuetrue if the ListMap contains the valueMap.containsValue(Object)public void putAll(Map<? extends K,? extends V> m)
Map to this ListMap.public void clear()
ListMap.clear in interface Map<K,V>Map.clear()public Collection<V> values()
Collection of the values in the ListMap.values in interface Map<K,V>Collection of valuesMap.values()public Set<Map.Entry<K,V>> entrySet()
Set of the key-value pairs in use in the ListMap.public int hashCode()
ListMap.public boolean equals(Object other)
ListMap with another object for equality.public String toString()
String (usually for diagnostic purposes).public ListMap.Entry<K,V> getEntry(int index)
ListMap.Entry by index.index - the indexprotected int findIndex(Object key)
key - the keyCopyright © 2020. All rights reserved.