Package com.yahoo.yolean.concurrent
Class CopyOnWriteHashMap<K,V>
java.lang.Object
com.yahoo.yolean.concurrent.CopyOnWriteHashMap<K,V>
- All Implemented Interfaces:
Map<K,V>
This is a thread hash map for small collections that are stable once built. Until it is stable there will be a race among all threads missing something in the map. They will then clone the map add the missing stuff and then put it back as active again. Here are no locks, but the cost is that inserts will happen a lot more than necessary. The map reference is volatile, but on most multi-cpu machines that has no cost unless modified.
- Author:
- baldersheim
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanisEmpty()keySet()voidintsize()values()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
CopyOnWriteHashMap
public CopyOnWriteHashMap()
-
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-