Colt 1.0.3

edu.oswego.cs.dl.util.concurrent
Class SyncMap

java.lang.Object
  |
  +--edu.oswego.cs.dl.util.concurrent.SyncMap
All Implemented Interfaces:
Map
Direct Known Subclasses:
SyncSortedMap

public class SyncMap
extends Object
implements Map

SyncMaps wrap Sync-based control around java.util.Maps. They operate in the same way as SyncCollection.

Reader operations are

Writer operations are:

[ Introduction to this package. ]

See Also:
SyncCollection

Inner classes inherited from class java.util.Map
Map.Entry
 
Constructor Summary
SyncMap(Map map, ReadWriteLock rwl)
          Create a new SyncMap protecting the given map, and using the given ReadWriteLock to control reader and writer methods.
SyncMap(Map map, Sync sync)
          Create a new SyncMap protecting the given map, and using the given sync to control both reader and writer methods.
SyncMap(Map map, Sync readLock, Sync writeLock)
          Create a new SyncMap protecting the given map, and using the given pair of locks to control reader and writer methods.
 
Method Summary
 void clear()
           
 boolean containsKey(Object o)
           
 boolean containsValue(Object o)
           
 Set entrySet()
           
 boolean equals(Object o)
           
 Object get(Object key)
           
 int hashCode()
           
 boolean isEmpty()
           
 Set keySet()
           
 Object put(Object key, Object value)
           
 void putAll(Map coll)
           
 Sync readerSync()
          Return the Sync object managing read-only operations
 Object remove(Object key)
           
 int size()
           
 long syncFailures()
          Return the number of synchronization failures for read-only operations
 Collection values()
           
 Sync writerSync()
          Return the Sync object managing mutative operations
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyncMap

public SyncMap(Map map,
               Sync sync)
Create a new SyncMap protecting the given map, and using the given sync to control both reader and writer methods. Common, reasonable choices for the sync argument include Mutex, ReentrantLock, and Semaphores initialized to 1.

SyncMap

public SyncMap(Map map,
               ReadWriteLock rwl)
Create a new SyncMap protecting the given map, and using the given ReadWriteLock to control reader and writer methods.

SyncMap

public SyncMap(Map map,
               Sync readLock,
               Sync writeLock)
Create a new SyncMap protecting the given map, and using the given pair of locks to control reader and writer methods.
Method Detail

readerSync

public Sync readerSync()
Return the Sync object managing read-only operations

writerSync

public Sync writerSync()
Return the Sync object managing mutative operations

syncFailures

public long syncFailures()
Return the number of synchronization failures for read-only operations

hashCode

public int hashCode()
Specified by:
hashCode in interface Map
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Specified by:
equals in interface Map
Overrides:
equals in class Object

size

public int size()
Specified by:
size in interface Map

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map

containsKey

public boolean containsKey(Object o)
Specified by:
containsKey in interface Map

containsValue

public boolean containsValue(Object o)
Specified by:
containsValue in interface Map

get

public Object get(Object key)
Specified by:
get in interface Map

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface Map

remove

public Object remove(Object key)
Specified by:
remove in interface Map

putAll

public void putAll(Map coll)
Specified by:
putAll in interface Map

clear

public void clear()
Specified by:
clear in interface Map

keySet

public Set keySet()
Specified by:
keySet in interface Map

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map

values

public Collection values()
Specified by:
values in interface Map

Colt 1.0.3

Submit a bug or feature. Check the Colt home page for the latest news.