java.lang.Object
com.sun.faces.util.MultiKeyConcurrentHashMap<K,V>
This code is based off the source for ConcurrentHashMap from JDK 5 with the ability of mapping multiple keys to a
single value.
- This Map implemenation does not support iteration through keys and/or values.
- This Map implementation is NOT Serialziable.
- This cannot be cast as a general Map implementation.
-
Constructor Summary
ConstructorDescriptionCreates a new, empty map with a default initial capacity, load factor, and concurrencyLevel.MultiKeyConcurrentHashMap
(int initialCapacity) Creates a new, empty map with the specified initial capacity, and with default load factor and concurrencyLevel.MultiKeyConcurrentHashMap
(int initialCapacity, float loadFactor, int concurrencyLevel) Creates a new, empty map with the specified initial capacity, load factor, and concurrency level. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all mappings from this map.boolean
Legacy method testing if some key maps into the specified value in this table.boolean
containsKey
(Object key) Tests if the specified object is a key in this table.boolean
containsKey
(Object key1, Object key2) boolean
containsKey
(Object key1, Object key2, Object key3) boolean
containsKey
(Object key1, Object key2, Object key3, Object key4) boolean
containsValue
(Object value) Returnstrue
if this map maps one or more keys to the specified value.entrySet()
Unsupported.Returns the value to which the specified key is mapped in this table.boolean
isEmpty()
keySet()
UnsupportedMaps the specifiedkey
to the specifiedvalue
in this table.putIfAbsent
(K key1, K key2, K key3, V value) putIfAbsent
(K key1, K key2, V value) putIfAbsent
(K key, V value) If the specified key is not already associated with a value, associate it with the given value.Replace entry for key only if currently mapped to some value.boolean
Replace entry for key only if currently mapped to given value.int
size()
values()
Unsupported.
-
Constructor Details
-
MultiKeyConcurrentHashMap
public MultiKeyConcurrentHashMap(int initialCapacity, float loadFactor, int concurrencyLevel) Creates a new, empty map with the specified initial capacity, load factor, and concurrency level.- Parameters:
initialCapacity
- the initial capacity. The implementation performs internal sizing to accommodate this many elements.loadFactor
- the load factor threshold, used to control resizing. Resizing may be performed when the average number of elements per bin exceeds this threshold.concurrencyLevel
- the estimated number of concurrently updating threads. The implementation performs internal sizing to try to accommodate this many threads.- Throws:
IllegalArgumentException
- if the initial capacity is negative or the load factor or concurrencyLevel are nonpositive.
-
MultiKeyConcurrentHashMap
public MultiKeyConcurrentHashMap(int initialCapacity) Creates a new, empty map with the specified initial capacity, and with default load factor and concurrencyLevel.- Parameters:
initialCapacity
- the initial capacity. The implementation performs internal sizing to accommodate this many elements.- Throws:
IllegalArgumentException
- if the initial capacity of elements is negative.
-
MultiKeyConcurrentHashMap
public MultiKeyConcurrentHashMap()Creates a new, empty map with a default initial capacity, load factor, and concurrencyLevel.
-
-
Method Details
-
isEmpty
public boolean isEmpty()- See Also:
-
size
public int size()- See Also:
-
get
Returns the value to which the specified key is mapped in this table.- Parameters:
key
- a key in the table.- Returns:
- the value to which the key is mapped in this table;
null
if the key is not mapped to any value in this table. - Throws:
NullPointerException
- if the key isnull
.
-
get
-
get
-
get
-
containsKey
Tests if the specified object is a key in this table.- Parameters:
key
- possible key.- Returns:
true
if and only if the specified object is a key in this table, as determined by theequals
method;false
otherwise.- Throws:
NullPointerException
- if the key isnull
.
-
containsKey
-
containsKey
-
containsKey
-
containsValue
Returnstrue
if this map maps one or more keys to the specified value. Note: This method requires a full internal traversal of the hash table, and so is much slower than methodcontainsKey
.- Parameters:
value
- value whose presence in this map is to be tested.- Returns:
true
if this map maps one or more keys to the specified value.- Throws:
NullPointerException
- if the value isnull
.
-
contains
Legacy method testing if some key maps into the specified value in this table. This method is identical in functionality tocontainsValue(java.lang.Object)
, and exists solely to ensure full compatibility with classHashtable
, which supported this method prior to introduction of the Java Collections framework.- Parameters:
value
- a value to search for.- Returns:
true
if and only if some key maps to thevalue
argument in this table as determined by theequals
method;false
otherwise.- Throws:
NullPointerException
- if the value isnull
.
-
put
Maps the specifiedkey
to the specifiedvalue
in this table. Neither the key nor the value can benull
.The value can be retrieved by calling the
get
method with a key that is equal to the original key.- Parameters:
key
- the table key.value
- the value.- Returns:
- the previous value of the specified key in this table, or
null
if it did not have one. - Throws:
NullPointerException
- if the key or value isnull
.
-
put
-
put
-
put
-
putIfAbsent
If the specified key is not already associated with a value, associate it with the given value. This is equivalent toif (!map.containsKey(key)) return map.put(key, value); else return map.get(key);
Except that the action is performed atomically.- Parameters:
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.- Returns:
- previous value associated with specified key, or
null
if there was no mapping for key. - Throws:
NullPointerException
- if the specified key or value isnull
.
-
putIfAbsent
-
putIfAbsent
-
putIfAbsent
-
remove
-
remove
-
remove
-
remove
-
replace
Replace entry for key only if currently mapped to given value. Acts asif (map.get(key).equals(oldValue)) { map.put(key, newValue); return true; } else return false;
except that the action is performed atomically.- Parameters:
key
- key with which the specified value is associated.oldValue
- value expected to be associated with the specified key.newValue
- value to be associated with the specified key.- Returns:
- true if the value was replaced
- Throws:
NullPointerException
- if the specified key or values arenull
.
-
replace
Replace entry for key only if currently mapped to some value. Acts asif ((map.containsKey(key)) { return map.put(key, value); } else return null;
except that the action is performed atomically.- Parameters:
key
- key with which the specified value is associated.value
- value to be associated with the specified key.- Returns:
- previous value associated with specified key, or
null
if there was no mapping for key. - Throws:
NullPointerException
- if the specified key or value isnull
.
-
clear
public void clear()Removes all mappings from this map. -
keySet
-
values
Unsupported. -
entrySet
-