K - the type of keys maintained by this mappublic class KeyMap<K extends KeyMap.HashItem> extends Inlist<KeyMap<K>>
KeyMap is not synchronized. If one thread
of several threads accessing an instance modifies the map structurally,
access to the map needs to be synchronized. A structural modification is an
operation that adds or removes an entry. Changes in the value of an entry are
not structural changes.| Modifier and Type | Class and Description |
|---|---|
static class |
KeyMap.HashItem |
Inlist.List<T extends Inlist<?>>| Constructor and Description |
|---|
KeyMap()
Constructs a new empty
HashMap instance. |
KeyMap(int capacity)
Constructs a new
HashMap instance with the specified capacity. |
KeyMap(int capacity,
float loadFactor)
Constructs a new
HashMap instance with the specified capacity and
load factor. |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all mappings from this hash map, leaving it empty.
|
K |
get(KeyMap.HashItem key)
Returns the value of the mapping with the specified key.
|
boolean |
isEmpty()
Returns whether this map is empty.
|
K |
put(K key)
Maps the specified key to the specified value.
|
K |
put(K key,
boolean replace) |
K |
releaseItems() |
K |
remove(K key)
Removes the mapping with the specified key from this map.
|
int |
size()
Returns the number of elements in this map.
|
appendItem, appendList, get, last, next, prependRelative, push, remove, sizepublic KeyMap()
HashMap instance.public KeyMap(int capacity)
HashMap instance with the specified capacity.capacity - the initial capacity of this hash map.java.lang.IllegalArgumentException - when the capacity is less than zero.public KeyMap(int capacity,
float loadFactor)
HashMap instance with the specified capacity and
load factor.capacity - the initial capacity of this hash map.loadFactor - the initial load factor.java.lang.IllegalArgumentException - when the capacity is less than zero or the load factor is
less or equal to zero or NaN.public boolean isEmpty()
true if this map has no elements, false
otherwise.size()public int size()
public K get(KeyMap.HashItem key)
key - the key.null
if no mapping for the specified key is found.public K put(K key)
key - the key.value - the value.null if there was no such mapping.public K remove(K key)
key - the key of the mapping to remove.null if no mapping
for the specified key was found.public void clear()
public K releaseItems()