Class CopyOnWriteMap<K,V>
java.lang.Object
org.apache.mina.util.CopyOnWriteMap<K,V>
- Type Parameters:
K- The key typeV- The value type
A thread-safe version of
Map in which all operations that change the
Map are implemented by making a new copy of the underlying Map.
While the creation of a new Map can be expensive, this class is designed for
cases in which the primary function is to read data from the Map, not to
modify the Map. Therefore the operations that do not cause a change to this
class happen quickly and concurrently.-
Nested Class Summary
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of CopyOnWriteMap.CopyOnWriteMap(int initialCapacity) Creates a new instance of CopyOnWriteMap with the specified initial sizeCopyOnWriteMap(Map<K, V> data) Creates a new instance of CopyOnWriteMap in which the initial data being held by this map is contained in the supplied map. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all entries in this map.clone()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()This method will return a read-onlySet.booleanisEmpty()keySet()This method will return a read-onlySet.Adds the provided key and value to this map.voidInserts all the keys and values contained in the provided map to this map.Removed the value and key from this map based on the provided key.intsize()values()This method will return a read-onlyCollection.Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
internalMap
-
-
Constructor Details
-
CopyOnWriteMap
public CopyOnWriteMap()Creates a new instance of CopyOnWriteMap. -
CopyOnWriteMap
public CopyOnWriteMap(int initialCapacity) Creates a new instance of CopyOnWriteMap with the specified initial size- Parameters:
initialCapacity- The initial size of the Map.
-
CopyOnWriteMap
-
-
Method Details
-
put
-
remove
-
putAll
-
clear
-
size
-
isEmpty
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V> - Returns:
- true if this map contains the provided key, otherwise this method return false.
- See Also:
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V> - Returns:
- true if this map contains the provided value, otherwise this method returns false.
- See Also:
-
get
-
keySet
-
values
This method will return a read-onlyCollection. -
entrySet
-
clone
-