|
|||||||||
| Home >> All >> java >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.util
Class Collections.SynchronizedSortedSet

java.lang.Objectjava.util.Collections.SynchronizedCollection
java.util.Collections.SynchronizedSet
java.util.Collections.SynchronizedSortedSet
- All Implemented Interfaces:
- Collection, java.lang.Iterable, java.io.Serializable, Set, SortedSet
- Enclosing class:
- Collections
- private static final class Collections.SynchronizedSortedSet
- extends Collections.SynchronizedSet
- implements SortedSet
- extends Collections.SynchronizedSet
The implementation of Collections.synchronizedSortedSet(SortedSet) 55 . This
class name is required for compatibility with Sun's JDK serializability.
| Field Summary | |
(package private) Collection |
c
The wrapped collection. |
(package private) java.lang.Object |
mutex
The object to synchronize on. |
private static long |
serialVersionUID
Compatible with JDK 1.4. |
private SortedSet |
ss
The wrapped set; stored both here and in the superclass to avoid excessive casting. |
| Constructor Summary | |
(package private) |
Collections.SynchronizedSortedSet(java.lang.Object sync,
SortedSet ss)
Called only by trusted code to specify the mutex as well as the set. |
(package private) |
Collections.SynchronizedSortedSet(SortedSet ss)
Wrap a given set. |
| Method Summary | |
boolean |
add(java.lang.Object o)
Adds the object to the underlying collection, first obtaining a lock on the mutex. |
boolean |
addAll(Collection col)
Adds the objects in col to the underlying collection, first obtaining a lock on the mutex. |
void |
clear()
Removes all objects from the underlying collection, first obtaining a lock on the mutex. |
Comparator |
comparator()
Returns the comparator used in sorting the underlying set, or null if it is the elements' natural ordering. |
boolean |
contains(java.lang.Object o)
Checks for the existence of o within the underlying collection, first obtaining a lock on the mutex. |
boolean |
containsAll(Collection c1)
Checks for the existence of each object in cl within the underlying collection, first obtaining a lock on the mutex. |
boolean |
equals(java.lang.Object o)
Returns true if the object, o, is a Set
of the same size as the underlying set, and contains
each element, e, which occurs in the underlying set. |
java.lang.Object |
first()
Returns the first, lowest sorted, element from the underlying set. |
int |
hashCode()
Computes the hash code for the underlying set as the sum of the hash code of all elements within the set. |
SortedSet |
headSet(java.lang.Object toElement)
Returns a subset containing the element from the first element (as returned by first()) to
the element before that specified. |
boolean |
isEmpty()
Returns true if there are no objects in the underlying
collection. |
Iterator |
iterator()
Returns a synchronized iterator wrapper around the underlying collection's iterator. |
java.lang.Object |
last()
Returns the last, highest sorted, element from the underlying set. |
boolean |
remove(java.lang.Object o)
Removes the specified object from the underlying collection, first obtaining a lock on the mutex. |
boolean |
removeAll(Collection col)
Removes all elements, e, of the underlying collection for which col.contains(e)
returns true. |
boolean |
retainAll(Collection col)
Retains all elements, e, of the underlying collection for which col.contains(e)
returns true. |
int |
size()
Retrieves the size of the underlying collection. |
SortedSet |
subSet(java.lang.Object fromElement,
java.lang.Object toElement)
Returns a subset containing the elements from fromElement to the element before toElement. |
SortedSet |
tailSet(java.lang.Object fromElement)
Returns a subset containing all the elements from fromElement onwards. |
java.lang.Object[] |
toArray()
Returns an array containing each object within the underlying collection. |
java.lang.Object[] |
toArray(java.lang.Object[] a)
Copies the elements in the underlying collection to the supplied array. |
java.lang.String |
toString()
Returns a string representation of the underlying collection. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
| Field Detail |
serialVersionUID
private static final long serialVersionUID
- Compatible with JDK 1.4.
- See Also:
- Constant Field Values
ss
private final SortedSet ss
- The wrapped set; stored both here and in the superclass to avoid
excessive casting.
c
final Collection c
- The wrapped collection. Package visible for use by subclasses.
mutex
final java.lang.Object mutex
- The object to synchronize on. When an instance is created via public
methods, it will be this; but other uses like SynchronizedMap.values()
must specify another mutex. Package visible for use by subclasses.
| Constructor Detail |
Collections.SynchronizedSortedSet
Collections.SynchronizedSortedSet(SortedSet ss)
- Wrap a given set.
Collections.SynchronizedSortedSet
Collections.SynchronizedSortedSet(java.lang.Object sync, SortedSet ss)
- Called only by trusted code to specify the mutex as well as the set.
| Method Detail |
comparator
public Comparator comparator()
- Returns the comparator used in sorting the underlying set, or null if
it is the elements' natural ordering. A lock is obtained on the mutex
before the comparator is retrieved.
- Specified by:
comparatorin interfaceSortedSet
first
public java.lang.Object first()
- Returns the first, lowest sorted, element from the underlying set.
A lock is obtained on the mutex before the set is accessed.
headSet
public SortedSet headSet(java.lang.Object toElement)
- Returns a subset containing the element from the first
element (as returned by
first()) to the element before that specified. The subset supports all operations supported by the underlying set and all actions taking place on the subset are also reflected in the underlying set. A lock is obtained on the mutex prior to subset creation. This operation is equivalent tosubSet(first(), toElement). The subset retains the thread-safe status of this set.
last
public java.lang.Object last()
- Returns the last, highest sorted, element from the underlying set.
A lock is obtained on the mutex before the set is accessed.
subSet
public SortedSet subSet(java.lang.Object fromElement, java.lang.Object toElement)
- Returns a subset containing the elements from fromElement to
the element before toElement. The subset supports all
operations supported by the underlying set and all actions
taking place on the subset are also reflected in the underlying
set. A lock is obtained on the mutex prior to subset creation.
The subset retains the thread-safe status of this set.
tailSet
public SortedSet tailSet(java.lang.Object fromElement)
- Returns a subset containing all the elements from fromElement onwards.
The subset supports all operations supported by the underlying
set and all actions taking place on the subset are also reflected
in the underlying set. A lock is obtained on the mutex prior to
subset creation. The subset retains the thread-safe status of
this set.
equals
public boolean equals(java.lang.Object o)
- Returns
trueif the object, o, is aSetof the same size as the underlying set, and contains each element, e, which occurs in the underlying set. A lock is obtained on the mutex before the comparison takes place.
hashCode
public int hashCode()
- Computes the hash code for the underlying set as the
sum of the hash code of all elements within the set.
A lock is obtained on the mutex before the computation
occurs.
add
public boolean add(java.lang.Object o)
- Adds the object to the underlying collection, first
obtaining a lock on the mutex.
- Specified by:
addin interfaceCollection
addAll
public boolean addAll(Collection col)
- Adds the objects in col to the underlying collection, first
obtaining a lock on the mutex.
- Specified by:
addAllin interfaceCollection
clear
public void clear()
- Removes all objects from the underlying collection,
first obtaining a lock on the mutex.
- Specified by:
clearin interfaceCollection
contains
public boolean contains(java.lang.Object o)
- Checks for the existence of o within the underlying
collection, first obtaining a lock on the mutex.
- Specified by:
containsin interfaceCollection
containsAll
public boolean containsAll(Collection c1)
- Checks for the existence of each object in cl
within the underlying collection, first obtaining
a lock on the mutex.
- Specified by:
containsAllin interfaceCollection
isEmpty
public boolean isEmpty()
- Returns
trueif there are no objects in the underlying collection. A lock on the mutex is obtained before the check is performed.- Specified by:
isEmptyin interfaceCollection
iterator
public Iterator iterator()
- Returns a synchronized iterator wrapper around the underlying
collection's iterator. A lock on the mutex is obtained before
retrieving the collection's iterator.
- Specified by:
iteratorin interfaceCollection
remove
public boolean remove(java.lang.Object o)
- Removes the specified object from the underlying collection,
first obtaining a lock on the mutex.
- Specified by:
removein interfaceCollection
removeAll
public boolean removeAll(Collection col)
- Removes all elements, e, of the underlying
collection for which
col.contains(e)returnstrue. A lock on the mutex is obtained before the operation proceeds.- Specified by:
removeAllin interfaceCollection
retainAll
public boolean retainAll(Collection col)
- Retains all elements, e, of the underlying
collection for which
col.contains(e)returnstrue. That is, every element that doesn't exist in col is removed. A lock on the mutex is obtained before the operation proceeds.- Specified by:
retainAllin interfaceCollection
size
public int size()
- Retrieves the size of the underlying collection.
A lock on the mutex is obtained before the collection
is accessed.
- Specified by:
sizein interfaceCollection
toArray
public java.lang.Object[] toArray()
- Returns an array containing each object within the underlying
collection. A lock is obtained on the mutex before the collection
is accessed.
- Specified by:
toArrayin interfaceCollection
toArray
public java.lang.Object[] toArray(java.lang.Object[] a)
- Copies the elements in the underlying collection to the supplied
array. If
a.length < size(), a new array of the same run-time type is created, with a size equal to that of the collection. Ifa.length > size(), then the elements from 0 tosize() - 1contain the elements from this collection. The following element is set to null to indicate the end of the collection objects. However, this only makes a difference if null is not a permitted value within the collection. Before the copying takes place, a lock is obtained on the mutex.- Specified by:
toArrayin interfaceCollection
toString
public java.lang.String toString()
- Returns a string representation of the underlying collection.
A lock is obtained on the mutex before the string is created.
|
|||||||||
| Home >> All >> java >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC