Package com.sun.faces.util
Class MultiKeyConcurrentHashMap<K,V>
java.lang.Object
com.sun.faces.util.MultiKeyConcurrentHashMap<K,V>
public class MultiKeyConcurrentHashMap<K,V> extends Object
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
Constructors Constructor Description MultiKeyConcurrentHashMap()
Creates 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 Type Method Description void
clear()
Removes all mappings from this map.boolean
contains(Object value)
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)
Returns true if this map maps one or more keys to the specified value.Set<Map.Entry<K,V>>
entrySet()
Unsupported.V
get(Object key)
Returns the value to which the specified key is mapped in this table.V
get(Object key1, Object key2)
V
get(Object key1, Object key2, Object key3)
V
get(Object key1, Object key2, Object key3, Object key4)
boolean
isEmpty()
Set<K>
keySet()
UnsupportedV
put(K key1, K key2, K key3, K key4, V value)
V
put(K key1, K key2, K key3, V value)
V
put(K key1, K key2, V value)
V
put(K key, V value)
Maps the specified key to the specified value in this table.V
putIfAbsent(K key1, K key2, K key3, K key4, V value)
V
putIfAbsent(K key1, K key2, K key3, V value)
V
putIfAbsent(K key1, K key2, V value)
V
putIfAbsent(K key, V value)
If the specified key is not already associated with a value, associate it with the given value.V
remove(K key)
V
remove(K key1, K key2)
V
remove(K key1, K key2, K key3)
V
remove(K key1, K key2, K key3, K key4)
V
replace(K key, V value)
Replace entry for key only if currently mapped to some value.boolean
replace(K key, V oldValue, V newValue)
Replace entry for key only if currently mapped to given value.int
size()
Collection<V>
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:
Map.isEmpty()
-
size
public int size()- See Also:
Map.size()
-
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 is null.
-
get
- See Also:
get(Object)
-
get
- See Also:
get(Object)
-
get
- See Also:
get(Object)
-
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 the equals method; false otherwise.
- Throws:
NullPointerException
- if the key is null.
-
containsKey
- See Also:
containsKey(Object)
-
containsKey
- See Also:
containsKey(Object)
-
containsKey
- See Also:
containsKey(Object)
-
containsValue
Returns true 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 method containsKey.- 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 is null.
-
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 the value argument in this table as determined by the equals method; false otherwise.
- Throws:
NullPointerException
- if the value is null.
-
put
Maps the specified key to the specified value in this table. Neither the key nor the value can be null.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 is null.
-
put
- See Also:
put(Object, Object)
-
put
- See Also:
put(Object, Object)
-
put
- See Also:
put(Object, Object)
-
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 is null.
-
putIfAbsent
- See Also:
putIfAbsent(Object, Object)
-
putIfAbsent
- See Also:
putIfAbsent(Object, Object)
-
putIfAbsent
- See Also:
putIfAbsent(Object, Object)
-
remove
- See Also:
Map.remove(Object)
-
remove
- See Also:
Map.remove(Object)
-
remove
- See Also:
Map.remove(Object)
-
remove
- See Also:
Map.remove(Object)
-
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 are null.
-
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 is null.
-
clear
public void clear()Removes all mappings from this map. -
keySet
Unsupported -
values
Unsupported. -
entrySet
Unsupported.
-