Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


com.tangosol.util
Class CopyOnWriteMap

java.lang.Object
  extended by com.tangosol.util.CopyOnWriteMap

All Implemented Interfaces:
java.util.Map

public class CopyOnWriteMap
extends java.lang.Object
implements java.util.Map

A thread-safe variant of Map in which all mutating operations (e.g. put, putAll) are implemented by making a fresh copy of the underlying map.

Iterators over this map are guaranteed to produce a safe-iteration and not to throw ConcurrentModificationException. The iterator will not reflect concurrent additions, removals, or changes to this map. Mutating operations on iterators themselves (e.g. remove, setValue) are not supported (and will throw UnsupportedOperationException).

Note: mutations on this map are costly, but may be more efficient than alternatives when "get" operations vastly outnumber mutations. All mutating operations are synchronized, so concurrent mutation can be prevented by holding synchronization on this object.

Since:
Coherence 3.7.2
Author:
pp 2011.09.17, rhl 2010.09.09 (from CopyOnWriteLongArray)

Nested Class Summary

 

Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry

 

Constructor Summary
CopyOnWriteMap(java.lang.Class clazz)
           
CopyOnWriteMap(java.util.Map map)
          Construct a CopyOnWriteMap, initialized with the contents of the specified map.

 

Method Summary
 void clear()
          
 boolean containsKey(java.lang.Object oKey)
          
 boolean containsValue(java.lang.Object oValue)
          
protected  java.util.Map copyMap(java.util.Map map)
          Create an instance of Map based on the contents of the provided map.
 java.util.Set entrySet()
          
 boolean equals(java.lang.Object o)
          
 java.lang.Object get(java.lang.Object oKey)
          
protected  java.util.Map getInternalMap()
          Return the internal map.
 int hashCode()
          
protected  java.util.Map instantiateMap(java.lang.Class clazz)
          Create a new instance of Map based on the provided Class.
 boolean isEmpty()
          
 java.util.Set keySet()
          
 java.lang.Object put(java.lang.Object oKey, java.lang.Object oValue)
          
 void putAll(java.util.Map map)
          
 java.lang.Object remove(java.lang.Object oKey)
          
protected  void setInternalMap(java.util.Map map)
          Set the internal map.
 int size()
          
 java.lang.String toString()
          
 java.util.Collection values()
          

 

Constructor Detail

CopyOnWriteMap

public CopyOnWriteMap(java.lang.Class clazz)

CopyOnWriteMap

public CopyOnWriteMap(java.util.Map map)
Construct a CopyOnWriteMap, initialized with the contents of the specified map.
Parameters:
map - the initial map

Method Detail

getInternalMap

protected java.util.Map getInternalMap()
Return the internal map.
Returns:
the internal map

setInternalMap

protected void setInternalMap(java.util.Map map)
Set the internal map.
Parameters:
map - the new internal map

instantiateMap

protected java.util.Map instantiateMap(java.lang.Class clazz)
Create a new instance of Map based on the provided Class.
Parameters:
clazz - the type of Map to instantiate
Returns:
a new empty instance of Map
Throws:
java.lang.IllegalArgumentException - if the provided Class does not implement Map.

copyMap

protected java.util.Map copyMap(java.util.Map map)
Create an instance of Map based on the contents of the provided map.
Parameters:
map - the map to copy
Returns:
an instance of Map populated with the contents of the provided map

size

public int size()
Specified by:
size in interface java.util.Map

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object oKey)
Specified by:
containsKey in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object oValue)
Specified by:
containsValue in interface java.util.Map

get

public java.lang.Object get(java.lang.Object oKey)
Specified by:
get in interface java.util.Map

put

public java.lang.Object put(java.lang.Object oKey,
                            java.lang.Object oValue)
Specified by:
put in interface java.util.Map

remove

public java.lang.Object remove(java.lang.Object oKey)
Specified by:
remove in interface java.util.Map

putAll

public void putAll(java.util.Map map)
Specified by:
putAll in interface java.util.Map

clear

public void clear()
Specified by:
clear in interface java.util.Map

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map

values

public java.util.Collection values()
Specified by:
values in interface java.util.Map

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Map

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map

toString

public java.lang.String toString()

Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.