Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.ematgine.utils.concurrent
Class SyncSortedSet  view SyncSortedSet download SyncSortedSet.java

java.lang.Object
  extended byorg.ematgine.utils.concurrent.SyncCollection
      extended byorg.ematgine.utils.concurrent.SyncSet
          extended byorg.ematgine.utils.concurrent.SyncSortedSet
All Implemented Interfaces:
java.util.Collection, java.lang.Iterable, java.util.Set, java.util.SortedSet

public class SyncSortedSet
extends SyncSet
implements java.util.SortedSet

SyncSortedSets wrap Sync-based control around java.util.SortedSets. They support the following additional reader operations over SyncCollection: comparator, subSet, headSet, tailSet, first, last.

[ Introduction to this package. ]


Nested Class Summary
 
Nested classes inherited from class org.ematgine.utils.concurrent.SyncCollection
SyncCollection.SyncCollectionIterator
 
Field Summary
 
Fields inherited from class org.ematgine.utils.concurrent.SyncCollection
c_, rd_, syncFailures_, wr_
 
Constructor Summary
SyncSortedSet(java.util.SortedSet set, ReadWriteLock rwl)
          Create a new SyncSortedSet protecting the given set, and using the given ReadWriteLock to control reader and writer methods.
SyncSortedSet(java.util.SortedSet set, Sync sync)
          Create a new SyncSortedSet protecting the given collection, and using the given sync to control both reader and writer methods.
SyncSortedSet(java.util.SortedSet set, Sync readLock, Sync writeLock)
          Create a new SyncSortedSet protecting the given set, and using the given pair of locks to control reader and writer methods.
 
Method Summary
protected  java.util.SortedSet baseSortedSet()
           
 java.util.Comparator comparator()
          Returns the comparator used in sorting this set, or null if it is the elements' natural ordering.
 java.lang.Object first()
          Returns the first (lowest sorted) element in the set.
 java.util.SortedSet headSet(java.lang.Object toElement)
          Returns a view of the portion of the set strictly less than toElement.
 java.lang.Object last()
          Returns the last (highest sorted) element in the set.
 java.util.SortedSet subSet(java.lang.Object fromElement, java.lang.Object toElement)
          Returns a view of the portion of the set greater than or equal to fromElement, and strictly less than toElement.
 java.util.SortedSet tailSet(java.lang.Object fromElement)
          Returns a view of the portion of the set greater than or equal to fromElement.
 
Methods inherited from class org.ematgine.utils.concurrent.SyncSet
equals, hashCode
 
Methods inherited from class org.ematgine.utils.concurrent.SyncCollection
add, addAll, afterRead, beforeRead, clear, contains, containsAll, isEmpty, iterator, readerSync, remove, removeAll, retainAll, size, syncFailures, toArray, toArray, unprotectedIterator, writerSync
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, 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
 

Constructor Detail

SyncSortedSet

public SyncSortedSet(java.util.SortedSet set,
                     Sync sync)
Create a new SyncSortedSet protecting the given collection, 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.


SyncSortedSet

public SyncSortedSet(java.util.SortedSet set,
                     ReadWriteLock rwl)
Create a new SyncSortedSet protecting the given set, and using the given ReadWriteLock to control reader and writer methods.


SyncSortedSet

public SyncSortedSet(java.util.SortedSet set,
                     Sync readLock,
                     Sync writeLock)
Create a new SyncSortedSet protecting the given set, and using the given pair of locks to control reader and writer methods.

Method Detail

baseSortedSet

protected java.util.SortedSet baseSortedSet()

comparator

public java.util.Comparator comparator()
Description copied from interface: java.util.SortedSet
Returns the comparator used in sorting this set, or null if it is the elements' natural ordering.

Specified by:
comparator in interface java.util.SortedSet

first

public java.lang.Object first()
Description copied from interface: java.util.SortedSet
Returns the first (lowest sorted) element in the set.

Specified by:
first in interface java.util.SortedSet

last

public java.lang.Object last()
Description copied from interface: java.util.SortedSet
Returns the last (highest sorted) element in the set.

Specified by:
last in interface java.util.SortedSet

subSet

public java.util.SortedSet subSet(java.lang.Object fromElement,
                                  java.lang.Object toElement)
Description copied from interface: java.util.SortedSet
Returns a view of the portion of the set greater than or equal to fromElement, and strictly less than toElement. The view is backed by this set, so changes in one show up in the other. The subset supports all optional operations of the original.

The returned set throws an IllegalArgumentException any time an element is used which is out of the range of fromElement and toElement. Note that the lower endpoint is included, but the upper is not; if you want to change the inclusion or exclusion of an endpoint, pass its successor object in instead. For example, for Integers, you can request subSet(new Integer(lowlimit.intValue() + 1), new Integer(highlimit.intValue() + 1)) to reverse the inclusiveness of both endpoints.

Specified by:
subSet in interface java.util.SortedSet

headSet

public java.util.SortedSet headSet(java.lang.Object toElement)
Description copied from interface: java.util.SortedSet
Returns a view of the portion of the set strictly less than toElement. The view is backed by this set, so changes in one show up in the other. The subset supports all optional operations of the original.

The returned set throws an IllegalArgumentException any time an element is used which is out of the range of toElement. Note that the endpoint, toElement, is not included; if you want this value included, pass its successor object in to toElement. For example, for Integers, you could request headSet(new Integer(limit.intValue() + 1)).

Specified by:
headSet in interface java.util.SortedSet

tailSet

public java.util.SortedSet tailSet(java.lang.Object fromElement)
Description copied from interface: java.util.SortedSet
Returns a view of the portion of the set greater than or equal to fromElement. The view is backed by this set, so changes in one show up in the other. The subset supports all optional operations of the original.

The returned set throws an IllegalArgumentException any time an element is used which is out of the range of fromElement. Note that the endpoint, fromElement, is included; if you do not want this value to be included, pass its successor object in to fromElement. For example, for Integers, you could request tailSet(new Integer(limit.intValue() + 1)).

Specified by:
tailSet in interface java.util.SortedSet