Eclipse Platform
Release 3.6

org.eclipse.osgi.framework.eventmgr
Class CopyOnWriteIdentityMap

java.lang.Object
  extended by org.eclipse.osgi.framework.eventmgr.CopyOnWriteIdentityMap
All Implemented Interfaces:
Map

public class CopyOnWriteIdentityMap
extends Object
implements Map

A copy-on-write identity map. Write operations result in copying the underlying data so that simultaneous read operations are not affected. This allows for safe, unsynchronized traversal.

Note: This class uses identity for key and value comparison, not equals.

Since:
3.5

Constructor Summary
CopyOnWriteIdentityMap()
          Creates an empty map.
CopyOnWriteIdentityMap(CopyOnWriteIdentityMap source)
          Copy constructor.
 
Method Summary
 void clear()
          Remove all entries from the map.
 boolean containsKey(Object key)
          Check if the map contains the specified key.
 boolean containsValue(Object value)
          Check if the map contains the specified value.
 Set entrySet()
          Returns a snapshot of the entries in this map.
 Object get(Object key)
          Return the value object for the specified key.
 boolean isEmpty()
          Is the map empty?
 Set keySet()
          Returns a snapshot of the keys in this map.
 Object put(Object key, Object value)
          Add a key, value pair to the map.
 void putAll(Map source)
          Add all the entries from the specified map to this map.
 void putAll(Object[] keys)
          Add all the keys from the specified array to this map with the value null.
 Object remove(Object key)
          Remove a key from the map and returns the value associated with the key.
 int size()
          Return the number of entries in the map.
 Collection values()
          Returns a snapshot of the values in this map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

CopyOnWriteIdentityMap

public CopyOnWriteIdentityMap()
Creates an empty map.


CopyOnWriteIdentityMap

public CopyOnWriteIdentityMap(CopyOnWriteIdentityMap source)
Copy constructor.

Parameters:
source - The CopyOnWriteMap to copy.
Method Detail

put

public Object put(Object key,
                  Object value)
Add a key, value pair to the map. If the key object is already in the map, then its value is replaced with the new value. Keys are compared using identity.

Specified by:
put in interface Map
Parameters:
key - The key object to be added to the list.
value - The value object to be associated with the key. This may be null.
Returns:
null if the specified key was newly added to the map. Otherwise the previous value of the key.
Throws:
IllegalArgumentException - If key is null.

putAll

public void putAll(Map source)
Add all the entries from the specified map to this map.

Specified by:
putAll in interface Map
Parameters:
source - The map whose entries are to be added to this map.

putAll

public void putAll(Object[] keys)
Add all the keys from the specified array to this map with the value null.

Parameters:
keys - The array of keys to be added to this map.

remove

public Object remove(Object key)
Remove a key from the map and returns the value associated with the key. Key objects are compared using identity.

Specified by:
remove in interface Map
Parameters:
key - The key object to be removed from the map.
Returns:
null if the key was not in the list. Otherwise, the value associated with the key.
Throws:
IllegalArgumentException - If key is null.

clear

public void clear()
Remove all entries from the map.

Specified by:
clear in interface Map

isEmpty

public boolean isEmpty()
Is the map empty?

Specified by:
isEmpty in interface Map
Returns:
true if the list is empty.

size

public int size()
Return the number of entries in the map.

Specified by:
size in interface Map
Returns:
The number of entries in the map.

get

public Object get(Object key)
Return the value object for the specified key. Keys are compared using identity.

Specified by:
get in interface Map
Parameters:
key - The key object.
Returns:
The value object for the specified key.
Throws:
IllegalArgumentException - If key is null.

containsKey

public boolean containsKey(Object key)
Check if the map contains the specified key. Keys are compared using identity.

Specified by:
containsKey in interface Map
Parameters:
key - The key object.
Returns:
true if the specified key is in the map.
Throws:
IllegalArgumentException - If key is null.

containsValue

public boolean containsValue(Object value)
Check if the map contains the specified value. Values are compared using identity.

Specified by:
containsValue in interface Map
Parameters:
value - The value object.
Returns:
true if the specified value is in the map.

entrySet

public Set entrySet()
Returns a snapshot of the entries in this map. The returned set will NOT be changed by future changes to this map.

Specified by:
entrySet in interface Map
Returns:
A Set of Map.Entry for each entry in this map. The set and the entries returned by the set cannot be modified.

keySet

public Set keySet()
Returns a snapshot of the keys in this map. The returned set will NOT be changed by future changes to this map.

Specified by:
keySet in interface Map
Returns:
A Set of the key objects in this map The set cannot be modified.

values

public Collection values()
Returns a snapshot of the values in this map. The returned collection will NOT be changed by future changes to this map.

Specified by:
values in interface Map
Returns:
A Collection of the value objects in this map. The collection cannot be modified.

Eclipse Platform
Release 3.6

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2010. All rights reserved.