gausssoft.collections
Class SynchronizedSortedSet
java.lang.Object
|
+--gausssoft.collections.SynchronizedCollection
|
+--gausssoft.collections.SynchronizedSet
|
+--gausssoft.collections.SynchronizedSortedSet
- All Implemented Interfaces:
- Collection, Serializable, Set, SortedSet
- public class SynchronizedSortedSet
- extends SynchronizedSet
- implements SortedSet
The SynchronizedSortedSet class is used to synchronize all operations on a
SortedSet
object on a particular object.
Each method of this implementation synchronizes on a specified object specified
at construction time, and then calls the method of the same signature
of the backing collection. Each instance is serializable only if the backing
collection and mutex is serializable.
This is similar to the synchronization methods in Collections
, but
this implementation allows you to choose what object to synchronize on, and allows
subclassing.
The subSet(Object, Object)
, headSet(Object)
and
tailSet(Object)
methods all return SynchronizedSortedSet objects which
synchronize on the same mutex used by the parent SynchronizedSortedSet.
- Author:
- Allan Crooks
- See Also:
SortedSet
,
Collections
, Serialized Form
Methods inherited from class gausssoft.collections.SynchronizedCollection |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString |
Methods inherited from interface java.util.Set |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
root
protected final SortedSet root
- Backing set.
SynchronizedSortedSet
public SynchronizedSortedSet(SortedSet root,
Object mutex)
- Creates a new SynchronizedSortedSet.
- Parameters:
root
- The set to use as the backing set.mutex
- The object to synchronize operations on.- Throws:
NullPointerException
- If root is null
.
SynchronizedSortedSet
public SynchronizedSortedSet(SortedSet root)
- Creates a new SynchronizedSortedSet.
The object constructed will synchronize all operations on itself.
- Parameters:
root
- The set to use as the backing set.- Throws:
NullPointerException
- If root is null
.
comparator
public Comparator comparator()
- Specified by:
comparator
in interface SortedSet
subSet
public SortedSet subSet(Object fromElement,
Object toElement)
- Specified by:
subSet
in interface SortedSet
headSet
public SortedSet headSet(Object toElement)
- Specified by:
headSet
in interface SortedSet
tailSet
public SortedSet tailSet(Object fromElement)
- Specified by:
tailSet
in interface SortedSet
first
public Object first()
- Specified by:
first
in interface SortedSet
last
public Object last()
- Specified by:
last
in interface SortedSet