org.ozoneDB.collections
Class FullTreeSetImpl

java.lang.Object
  extended byorg.ozoneDB.OzoneObject
      extended byorg.ozoneDB.collections.AbstractOzoneCollection
          extended byorg.ozoneDB.collections.AbstractOzoneSet
              extended byorg.ozoneDB.collections.BaseTreeSetImpl
                  extended byorg.ozoneDB.collections.FullTreeSetImpl
All Implemented Interfaces:
BaseTreeSet, java.lang.Cloneable, java.util.Collection, FullTreeSet, OzoneCollection, org.ozoneDB.OzoneCompatible, org.ozoneDB.OzoneCompatibleOrProxy, org.ozoneDB.OzoneRemote, OzoneSet, OzoneSortedSet, OzoneTreeSet, java.io.Serializable, java.util.Set, java.util.SortedSet

public class FullTreeSetImpl
extends BaseTreeSetImpl
implements FullTreeSet

Note that calling iterator() results in the creation of an ozone object and thus in a write-action for the db.

Author:
Leo Mekenkamp (mind the anti-sp@m)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.ozoneDB.collections.BaseTreeSetImpl
map
 
Constructor Summary
FullTreeSetImpl()
          Construct a new TreeSet whose backing TreeMap using the "natural" ordering of keys.
FullTreeSetImpl(java.util.Collection collection)
          Construct a new TreeSet whose backing TreeMap uses the "natural" orering of the keys and which contains all of the elements in the supplied Collection.
FullTreeSetImpl(java.util.Comparator comparator)
          Construct a new TreeSet whose backing TreeMap uses the supplied Comparator.
FullTreeSetImpl(java.util.SortedMap backingMap, DoNotUse_SeeJavadoc x)
          DO NOT USE THIS CONSTRUCTOR YOURSELF, NOR USE EQUIVALENT CREATE METHOD FROM FACTORY.
FullTreeSetImpl(java.util.SortedSet sortedSet)
          Construct a new TreeSet, using the same key ordering as the supplied SortedSet and containing all of the elements in the supplied SortedSet.
 
Method Summary
 java.lang.Object clone()
          Returns a shallow copy of this Set.
 java.util.SortedSet headSet(java.lang.Object to)
          Returns a view of this Set including all elements less than to.
protected  java.util.SortedMap newBackingMap()
           
protected  java.util.SortedMap newBackingMap(java.util.Comparator comparator)
           
 java.util.SortedSet subSet(java.lang.Object from, java.lang.Object to)
          Returns a view of this Set including all elements greater or equal to from and less than to (a half-open interval).
 java.util.SortedSet tailSet(java.lang.Object from)
          Returns a view of this Set including all elements greater or equal to from.
 
Methods inherited from class org.ozoneDB.collections.BaseTreeSetImpl
_org_ozoneDB_internalIterator, add, addAll, clear, comparator, contains, first, getClientCollection, getClientSet, getClientSortedSet, getClientTreeSet, isEmpty, iterator, last, onCreate, ozoneHeadSet, ozoneSubSet, ozoneTailSet, remove, size, toString
 
Methods inherited from class org.ozoneDB.collections.AbstractOzoneSet
equals, hashCode, removeAll
 
Methods inherited from class org.ozoneDB.collections.AbstractOzoneCollection
containsAll, retainAll, toArray, toArray
 
Methods inherited from class org.ozoneDB.OzoneObject
container, database, deleteRecursive, getHandle, getObjectID, handle, onActivate, onDelete, onPassivate, requireWriteLocking, self, setContainer, toXML
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ozoneDB.collections.OzoneTreeSet
getClientTreeSet
 
Methods inherited from interface org.ozoneDB.collections.OzoneSortedSet
getClientSortedSet, ozoneHeadSet, ozoneSubSet, ozoneTailSet
 
Methods inherited from interface org.ozoneDB.collections.OzoneSet
getClientSet
 
Methods inherited from interface org.ozoneDB.collections.OzoneCollection
_org_ozoneDB_internalIterator, add, addAll, clear, getClientCollection, remove, removeAll, retainAll
 
Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, isEmpty, iterator, size, toArray, toArray
 
Methods inherited from interface org.ozoneDB.OzoneCompatibleOrProxy
getObjectID
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.util.SortedSet
comparator, first, last
 

Constructor Detail

FullTreeSetImpl

public FullTreeSetImpl()
Construct a new TreeSet whose backing TreeMap using the "natural" ordering of keys. Elements that are not mutually comparable will cause ClassCastExceptions down the road.

See Also:
Comparable

FullTreeSetImpl

public FullTreeSetImpl(java.util.Comparator comparator)
Construct a new TreeSet whose backing TreeMap uses the supplied Comparator. Elements that are not mutually comparable will cause ClassCastExceptions down the road.

Parameters:
comparator - the Comparator this Set will use

FullTreeSetImpl

public FullTreeSetImpl(java.util.Collection collection)
Construct a new TreeSet whose backing TreeMap uses the "natural" orering of the keys and which contains all of the elements in the supplied Collection. This runs in n*log(n) time.

Parameters:
collection - the new Set will be initialized with all of the elements in this Collection
Throws:
java.lang.ClassCastException - if the elements of the collection are not comparable
java.lang.NullPointerException - if the collection is null
See Also:
Comparable

FullTreeSetImpl

public FullTreeSetImpl(java.util.SortedSet sortedSet)
Construct a new TreeSet, using the same key ordering as the supplied SortedSet and containing all of the elements in the supplied SortedSet. This constructor runs in linear time.

Parameters:
sortedSet - the new TreeSet will use this SortedSet's comparator and will initialize itself with all its elements
Throws:
java.lang.NullPointerException - if sortedSet is null

FullTreeSetImpl

public FullTreeSetImpl(java.util.SortedMap backingMap,
                       DoNotUse_SeeJavadoc x)

DO NOT USE THIS CONSTRUCTOR YOURSELF, NOR USE EQUIVALENT CREATE METHOD FROM FACTORY.

This constructor is used to implement the subSet() calls around a backing TreeMap.SubMap.

Parameters:
backingMap - the submap
Method Detail

clone

public java.lang.Object clone()
Returns a shallow copy of this Set. The elements are not cloned.

Returns:
the cloned set

headSet

public java.util.SortedSet headSet(java.lang.Object to)
Returns a view of this Set including all elements less than to. The returned set is backed by the original, so changes in one appear in the other. The subset will throw an IllegalArgumentException for any attempt to access or add an element beyond the specified cutoff. The returned set does not include the endpoint; if you want inclusion, pass the successor element.

Specified by:
headSet in interface java.util.SortedSet
Parameters:
to - the (exclusive) cutoff point
Returns:
a view of the set less than the cutoff
Throws:
java.lang.ClassCastException - if to is not compatible with the comparator (or is not Comparable, for natural ordering)
java.lang.NullPointerException - if to is null, but the comparator does not tolerate null elements

subSet

public java.util.SortedSet subSet(java.lang.Object from,
                                  java.lang.Object to)
Returns a view of this Set including all elements greater or equal to from and less than to (a half-open interval). The returned set is backed by the original, so changes in one appear in the other. The subset will throw an IllegalArgumentException for any attempt to access or add an element beyond the specified cutoffs. The returned set includes the low endpoint but not the high; if you want to reverse this behavior on either end, pass in the successor element.

Specified by:
subSet in interface java.util.SortedSet
Parameters:
from - the (inclusive) low cutoff point
to - the (exclusive) high cutoff point
Returns:
a view of the set between the cutoffs
Throws:
java.lang.ClassCastException - if either cutoff is not compatible with the comparator (or is not Comparable, for natural ordering)
java.lang.NullPointerException - if from or to is null, but the comparator does not tolerate null elements
java.lang.IllegalArgumentException - if from is greater than to

tailSet

public java.util.SortedSet tailSet(java.lang.Object from)
Returns a view of this Set including all elements greater or equal to from. The returned set is backed by the original, so changes in one appear in the other. The subset will throw an IllegalArgumentException for any attempt to access or add an element beyond the specified cutoff. The returned set includes the endpoint; if you want to exclude it, pass in the successor element.

Specified by:
tailSet in interface java.util.SortedSet
Parameters:
from - the (inclusive) low cutoff point
Returns:
a view of the set above the cutoff
Throws:
java.lang.ClassCastException - if from is not compatible with the comparator (or is not Comparable, for natural ordering)
java.lang.NullPointerException - if from is null, but the comparator does not tolerate null elements

newBackingMap

protected java.util.SortedMap newBackingMap()
Specified by:
newBackingMap in class BaseTreeSetImpl

newBackingMap

protected java.util.SortedMap newBackingMap(java.util.Comparator comparator)
Specified by:
newBackingMap in class BaseTreeSetImpl


Copyright © 2004 The Ozone Database Project - www.ozone-db.org. All Rights Reserved.