|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ozoneDB.OzoneObject
org.ozoneDB.collections.AbstractOzoneCollection
org.ozoneDB.collections.AbstractOzoneSet
org.ozoneDB.collections.BaseTreeSetImpl
This class provides a TreeMap-backed implementation of the SortedSet
interface. The elements will be sorted according to their natural
order, or according to the provided Comparator
.
Most operations are O(log n), but there is so much overhead that this makes small sets expensive. Note that the ordering must be consistent with equals to correctly implement the Set interface. If this condition is violated, the set is still well-behaved, but you may have suprising results when comparing it to other sets.
This implementation is not synchronized. If you need to share this between
multiple threads, do something like:
SortedSet s
= Collections.synchronizedSortedSet(new TreeSet(...));
The iterators are fail-fast, meaning that any structural
modification, except for remove()
called on the iterator
itself, cause the iterator to throw a
ConcurrentModificationException
rather than exhibit
non-deterministic behavior.
Collection
,
Set
,
HashSet
,
LinkedHashSet
,
Comparable
,
Comparator
,
Collections.synchronizedSortedSet(SortedSet)
,
TreeMap
,
Serialized FormField Summary | |
protected java.util.SortedMap |
map
The SortedMap which backs this Set. |
Constructor Summary | |
|
BaseTreeSetImpl()
Construct a new TreeSet whose backing TreeMap using the "natural" ordering of keys. |
|
BaseTreeSetImpl(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. |
|
BaseTreeSetImpl(java.util.Comparator comparator)
Construct a new TreeSet whose backing TreeMap uses the supplied Comparator. |
protected |
BaseTreeSetImpl(int ctorWithoutCreatingNewBackingMap)
Basically a hack to prevent creationg of yet another map which backs this BaseTreeSet but will be overwritten almost immediately by ctor FullTreeSetImpl(SortedMap backingMap, DoNotUse_SeeJavadoc x) |
|
BaseTreeSetImpl(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.util.Iterator |
_org_ozoneDB_internalIterator()
|
boolean |
add(java.lang.Object obj)
Adds the spplied Object to the Set if it is not already in the Set; returns true if the element is added, false otherwise. |
boolean |
addAll(java.util.Collection c)
Adds all of the elements in the supplied Collection to this TreeSet. |
void |
clear()
Removes all elements in this Set. |
java.util.Comparator |
comparator()
Returns this Set's comparator. |
boolean |
contains(java.lang.Object obj)
Returns true if this Set contains the supplied Object, false otherwise. |
java.lang.Object |
first()
Returns the first (by order) element in this Set. |
java.util.Collection |
getClientCollection()
Returns a Collection that contains the same entries as this
persistent one; it is (by nature of the client-server enviromnent) always
a 'deep' copy of this OzoneCollection . |
java.util.Set |
getClientSet()
Returns a Set that contains the same entries as this
persistent one; it is (by nature of the client-server enviromnent) always
a 'deep' copy of this OzoneSet . |
java.util.SortedSet |
getClientSortedSet()
Returns a SortedSet that contains the same entries as this
persistent one; it is (by nature of the client-server enviromnent) always
a 'deep' copy of this OzoneSortedSet . |
java.util.TreeSet |
getClientTreeSet()
Returns a TreeSet that contains the same entries as this
persistent one; it is (by nature of the client-server enviromnent) always
a 'deep' copy of this OzoneTreeSet . |
boolean |
isEmpty()
Returns true if this Set has size 0, false otherwise. |
java.util.Iterator |
iterator()
Returns in Iterator over the elements in this TreeSet, which traverses in ascending order. |
java.lang.Object |
last()
Returns the last (by order) element in this Set. |
protected abstract java.util.SortedMap |
newBackingMap()
|
protected abstract java.util.SortedMap |
newBackingMap(java.util.Comparator comparator)
|
void |
onCreate()
|
OzoneSortedSet |
ozoneHeadSet(java.lang.Object toElement)
Basically nothing more than a typecasted HeadSet method.
|
OzoneSortedSet |
ozoneSubSet(java.lang.Object fromElement,
java.lang.Object toElement)
Basically nothing more than a typecasted SubSet method.
|
OzoneSortedSet |
ozoneTailSet(java.lang.Object toElement)
Basically nothing more than a typecasted TailSet method. |
boolean |
remove(java.lang.Object obj)
If the supplied Object is in this Set, it is removed, and true is returned; otherwise, false is returned. |
int |
size()
Returns the number of elements in this Set |
java.lang.String |
toString()
Returns a string representation of the object. |
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 |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.ozoneDB.collections.OzoneCollection |
removeAll, retainAll |
Methods inherited from interface java.util.Collection |
containsAll, equals, hashCode, toArray, toArray |
Methods inherited from interface org.ozoneDB.OzoneCompatibleOrProxy |
getObjectID |
Methods inherited from interface java.util.Set |
containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray |
Methods inherited from interface java.util.SortedSet |
headSet, subSet, tailSet |
Field Detail |
protected java.util.SortedMap map
Constructor Detail |
public BaseTreeSetImpl()
Comparable
protected BaseTreeSetImpl(int ctorWithoutCreatingNewBackingMap)
public BaseTreeSetImpl(java.util.Comparator comparator)
comparator
- the Comparator this Set will usepublic BaseTreeSetImpl(java.util.Collection collection)
collection
- the new Set will be initialized with all
of the elements in this Collection
java.lang.ClassCastException
- if the elements of the collection are not
comparable
java.lang.NullPointerException
- if the collection is nullComparable
public BaseTreeSetImpl(java.util.SortedSet sortedSet)
sortedSet
- the new TreeSet will use this SortedSet's comparator
and will initialize itself with all its elements
java.lang.NullPointerException
- if sortedSet is nullMethod Detail |
public void onCreate()
onCreate
in interface org.ozoneDB.OzoneCompatible
public boolean add(java.lang.Object obj)
add
in interface OzoneCollection
add
in class AbstractOzoneCollection
obj
- the Object to be added to this Set
java.lang.ClassCastException
- if the element cannot be compared with objects
already in the setpublic boolean addAll(java.util.Collection c)
addAll
in interface OzoneCollection
addAll
in class AbstractOzoneCollection
c
- The collection to add
java.lang.NullPointerException
- if c is null
java.lang.ClassCastException
- if an element in c cannot be compared with
objects already in the setAbstractOzoneCollection.add(Object)
public void clear()
clear
in interface OzoneCollection
clear
in class AbstractOzoneCollection
Iterator.remove()
public java.util.Comparator comparator()
comparator
in interface java.util.SortedSet
public boolean contains(java.lang.Object obj)
contains
in interface java.util.Collection
contains
in class AbstractOzoneCollection
obj
- the Object to check for
java.lang.ClassCastException
- if obj cannot be compared with objects
already in the setpublic java.lang.Object first()
first
in interface java.util.SortedSet
java.util.NoSuchElementException
- if the set is emptypublic boolean isEmpty()
isEmpty
in interface java.util.Collection
isEmpty
in class AbstractOzoneCollection
AbstractOzoneCollection.size()
public java.util.Iterator iterator()
iterator
in interface java.util.Collection
iterator
in class AbstractOzoneCollection
public java.util.Iterator _org_ozoneDB_internalIterator()
_org_ozoneDB_internalIterator
in interface OzoneCollection
public java.lang.Object last()
last
in interface java.util.SortedSet
java.util.NoSuchElementException
- if the set is emptypublic boolean remove(java.lang.Object obj)
remove
in interface OzoneCollection
remove
in class AbstractOzoneCollection
obj
- the Object to remove from this Set
java.lang.ClassCastException
- if obj cannot be compared to set elementsIterator.remove()
public int size()
size
in interface java.util.Collection
size
in class AbstractOzoneCollection
public java.util.Collection getClientCollection()
Returns a Collection
that contains the same entries as this
persistent one; it is (by nature of the client-server enviromnent) always
a 'deep' copy of this OzoneCollection
. I.e. the contents of
this OzoneCollection
instance are always copied to the client
by use of serialization.
Note that the difference of calling iterator()
compared to getClientCollection().iterator()
is that in
the first case you go through the real collection on the server and in
the second case you go through a local copy on the client side.
Note that all subclasses of OzoneCollection
(or
OzoneMap
) have getClientXxx()
member functions
that returns a collection of type Xxx
; these simply return
a typecasted result value from getClientCollection()
or
getClientMap
.
getClientCollection
in interface OzoneCollection
getClientCollection
in class AbstractOzoneCollection
public java.util.Set getClientSet()
Returns a Set
that contains the same entries as this
persistent one; it is (by nature of the client-server enviromnent) always
a 'deep' copy of this OzoneSet
. I.e. the contents of
this OzoneSet
instance are always copied to the client
by use of serialization.
Note that the difference of calling iterator()
compared to getClientSet().iterator()
is that in
the first case you go through the real collection on the server and in
the second case you go through a local copy on the client side.
getClientSet
in interface OzoneSet
getClientSet
in class AbstractOzoneSet
public java.util.SortedSet getClientSortedSet()
Returns a SortedSet
that contains the same entries as this
persistent one; it is (by nature of the client-server enviromnent) always
a 'deep' copy of this OzoneSortedSet
. I.e. the contents of
this OzoneSortedSet
instance are always copied to the client
by use of serialization.
Note that the difference of calling iterator()
compared to getClientSortedSet().iterator()
is that in
the first case you go through the real collection on the server and in
the second case you go through a local copy on the client side.
getClientSortedSet
in interface OzoneSortedSet
public OzoneSortedSet ozoneHeadSet(java.lang.Object toElement)
Basically nothing more than a typecasted HeadSet
method.
Because subsets are also OzoneSortedSet
s, this method is
provided to do away with the need for a typecast.
ozoneHeadSet
in interface OzoneSortedSet
public OzoneSortedSet ozoneSubSet(java.lang.Object fromElement, java.lang.Object toElement)
Basically nothing more than a typecasted SubSet
method.
Because subsets are also OzoneSortedSet
s, this method is
provided to do away with the need for a typecast.
ozoneSubSet
in interface OzoneSortedSet
public OzoneSortedSet ozoneTailSet(java.lang.Object toElement)
Basically nothing more than a typecasted TailSet
method.
OzoneSortedSet
s, this method is
provided to do away with the need for a typecast.
ozoneTailSet
in interface OzoneSortedSet
public java.util.TreeSet getClientTreeSet()
Returns a TreeSet
that contains the same entries as this
persistent one; it is (by nature of the client-server enviromnent) always
a 'deep' copy of this OzoneTreeSet
. I.e. the contents of
this OzoneTreeSet
instance are always copied to the client
by use of serialization.
Note that the difference of calling iterator()
compared to getClientTreeSet().iterator()
is that in
the first case you go through the real collection on the server and in
the second case you go through a local copy on the client side.
getClientTreeSet
in interface OzoneTreeSet
public java.lang.String toString()
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString
in class AbstractOzoneCollection
protected abstract java.util.SortedMap newBackingMap()
protected abstract java.util.SortedMap newBackingMap(java.util.Comparator comparator)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |