Package org.oscim.utils
Class KeyMap<K extends KeyMap.HashItem>
- Type Parameters:
K- the type of keys maintained by this map
Note: the implementation of
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.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.oscim.utils.pool.Inlist
Inlist.List<T extends Inlist<?>> -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all mappings from this hash map, leaving it empty.get(KeyMap.HashItem key) Returns the value of the mapping with the specified key.booleanisEmpty()Returns whether this map is empty.Maps the specified key to the specified value.Removes the mapping with the specified key from this map.intsize()Returns the number of elements in this map.Methods inherited from class org.oscim.utils.pool.Inlist
appendItem, appendList, get, last, next, prependRelative, push, remove, size
-
Constructor Details
-
KeyMap
public KeyMap()Constructs a new emptyHashMapinstance. -
KeyMap
public KeyMap(int capacity) Constructs a newHashMapinstance with the specified capacity.- Parameters:
capacity- the initial capacity of this hash map.- Throws:
IllegalArgumentException- when the capacity is less than zero.
-
KeyMap
public KeyMap(int capacity, float loadFactor) Constructs a newHashMapinstance with the specified capacity and load factor.- Parameters:
capacity- the initial capacity of this hash map.loadFactor- the initial load factor.- Throws:
IllegalArgumentException- when the capacity is less than zero or the load factor is less or equal to zero or NaN.
-
-
Method Details
-
isEmpty
public boolean isEmpty()Returns whether this map is empty.- Returns:
trueif this map has no elements,falseotherwise.- See Also:
-
size
public int size()Returns the number of elements in this map.- Returns:
- the number of elements in this map.
-
get
Returns the value of the mapping with the specified key.- Parameters:
key- the key.- Returns:
- the value of the mapping with the specified key, or
nullif no mapping for the specified key is found.
-
put
Maps the specified key to the specified value.- Parameters:
key- the key.value- the value.- Returns:
- the value of any previous mapping with the specified key or
nullif there was no such mapping.
-
put
-
remove
Removes the mapping with the specified key from this map.- Parameters:
key- the key of the mapping to remove.- Returns:
- the value of the removed mapping or
nullif no mapping for the specified key was found.
-
clear
public void clear()Removes all mappings from this hash map, leaving it empty.- See Also:
-
isEmpty()size
-
releaseItems
-