Package com.yahoo.collections
Class CopyOnWriteHashMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
com.yahoo.collections.CopyOnWriteHashMap<K,V>
A hashmap wrapper which defers cloning of the enclosed map until it is written to.
Use this to make clones cheap in maps which are often not further modified.
As with regular maps, this can only be used safely if the content of the map is immutable.
If not, the copyMap(java.util.Map<K, V>)
method can be overridden to perform a deep clone.
- Author:
- bratseth
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
-
Method Summary
Methods inherited from class java.util.AbstractMap
clear, containsKey, containsValue, get, isEmpty, keySet, putAll, size, toString, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
CopyOnWriteHashMap
public CopyOnWriteHashMap() -
CopyOnWriteHashMap
public CopyOnWriteHashMap(int capacity) -
CopyOnWriteHashMap
-
-
Method Details
-
copyMap
Make a copy of the given map with the requisite deepness. This default implementation does return new HashMap<>(original); -
clone
- Overrides:
clone
in classAbstractMap<K,
V>
-
entrySet
-
put
-
remove
Override to avoid using iterator.remove -
equals
-
hashCode
public int hashCode()
-