public class ListHashMap<K,V>
extends HashMap<K,V>
Constructor and Description |
---|
ListHashMap()
Instantiates a new empty ListHashMap.
|
ListHashMap(boolean caseInsensitive)
Instantiates a new list hash map.
|
ListHashMap(int size)
Instantiates a new list hash map.
|
ListHashMap(int size,
boolean caseInsensitive)
Instantiates a new list hash map.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(V value)
Associates the specified value with the map.size + 1 in this map and add
value to the end of the list.
|
void |
clear() |
boolean |
containsKey(Object key) |
void |
copyAll(ListHashMap<K,V> source)
Copy all elements from the source map.
|
List<V> |
createList()
Creates the list.
|
List<V> |
createList(int size)
Creates the list.
|
V |
get(int index)
Returns the element at the specified position in the list.
|
V |
get(Object key) |
List<V> |
getList()
Gets the list.
|
int |
indexOf(V value)
Returns the index of the first occurrence of the specified element in
this list, or -1 if this list does not contain the element.
|
boolean |
isCaseInsensitive()
Checks if map is case insensitive.
|
V |
put(K key,
V value)
Associates the specified value with the specified key in this map and
adds value to the end of the list.
|
V |
put(K key,
V value,
int index)
Associates the specified value with the specified key in this map and
adds value to the list at the specified index.
|
V |
putKey(K key,
V value)
Associates the specified value with the specified key in this map and
adds key to the end of the list.
|
V |
remove(Object key)
Removes the mapping for a key from this map and from the list if it is
present.
|
V |
set(K key,
V value,
boolean replace)
If value associated with the key doesn't (or equal to null) associates
the specified value with the specified key in this map and adds value to
the end of the list.
|
public ListHashMap()
public ListHashMap(boolean caseInsensitive)
caseInsensitive
- the case insensitivepublic ListHashMap(int size)
size
- the sizepublic ListHashMap(int size, boolean caseInsensitive)
size
- the sizecaseInsensitive
- the case insensitivepublic boolean add(V value)
value
- the value to addpublic void clear()
public boolean containsKey(Object key)
public List<V> createList()
public List<V> createList(int size)
size
- the sizepublic V get(int index)
index
- index of the element to returnIndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())public V get(Object key)
public List<V> getList()
public int indexOf(V value)
value
- element to search forClassCastException
- if the type of the specified element is incompatible with
this list (optional)NullPointerException
- if the specified element is null and this list does not
permit null elements (optional)public boolean isCaseInsensitive()
public V put(K key, V value)
m.containsKey(k)
would return
true.)put
in interface Map<K,V>
put
in class HashMap<K,V>
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keyUnsupportedOperationException
- if the put operation is not supported by this mapClassCastException
- if the class of the specified key or value prevents it from
being stored in this mapNullPointerException
- if the specified key or value is null and this map does not
permit null keys or valuesIllegalArgumentException
- if some property of the specified key or value prevents it
from being stored in this mappublic V put(K key, V value, int index)
m.containsKey(k)
would return true.)key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keyindex
- the index of the value in the listUnsupportedOperationException
- if the put operation is not supported by this mapClassCastException
- if the class of the specified key or value prevents it from
being stored in this mapNullPointerException
- if the specified key or value is null and this map does not
permit null keys or valuesIllegalArgumentException
- if some property of the specified key or value prevents it
from being stored in this mappublic V putKey(K key, V value)
m.containsKey(k)
would return
true.)key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keyUnsupportedOperationException
- if the put operation is not supported by this mapClassCastException
- if the class of the specified key or value prevents it from
being stored in this mapNullPointerException
- if the specified key or value is null and this map does not
permit null keys or valuesIllegalArgumentException
- if some property of the specified key or value prevents it
from being stored in this mappublic V remove(Object key)
(key==null ? k==null : key.equals(k))
, that mapping is
removed. (The map can contain at most one such mapping.)
Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.
If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.
The map will not contain a mapping for the specified key once the call returns.
remove
in interface Map<K,V>
remove
in class HashMap<K,V>
key
- key whose mapping is to be removed from the mapUnsupportedOperationException
- if the remove operation is not supported by this mapClassCastException
- if the key is of an inappropriate type for this map
(optional)NullPointerException
- if the specified key is null and this map does not permit
null keys (optional)public V set(K key, V value, boolean replace)
replace
either returns old value associated with the key (if
replace == false) or associates the specified value with the key and
replaces value in the list at the index of the previous value in the
specified value.key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keyreplace
- if true
replaces existing association on the new
onepublic void copyAll(ListHashMap<K,V> source)
source
- the sourceCopyright © 2010-2020 Toolsverse. All Rights Reserved.