|
Oracle® Fusion Middleware Java API Reference for Oracle Coherence 12c (12.1.3.0.0) E47890-01 |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
java.util.AbstractCollection
com.tangosol.util.SortedBag
public class SortedBag
SortedBag is a multiset or bag implementation that supports sorted traversal of the contained elements and is optimized for insertions and removals.
This implementation is not thread-safe and does not support null elements.
| Nested Class Summary | |
|---|---|
protected class |
SortedBag.UniqueElementUniqueElement represents a unique instance of a logical element in the bag. |
protected class |
SortedBag.ViewBagA range-limited view of the SortedBag. |
protected static class |
SortedBag.WrapperComparatorWrapperComparator is a Comparator implementation that is aware of SortedBag.UniqueElement wrappers and will delegate the comparison of the elements in both forms to the wrapped comparator. |
| Field Summary | |
|---|---|
protected java.util.concurrent.atomic.AtomicLong |
m_atomicNonceThe nonce used to increment the unique element ids. |
protected java.util.Comparator |
m_comparatorThe comparator used to compare logical elements. |
protected java.util.NavigableMap |
m_mapThe internal sorted map holding the bag contents. |
protected static java.lang.Object |
NO_VALUEMarker value object. |
| Constructor Summary | |
|---|---|
protected |
SortedBag()Default constructor. |
|
SortedBag(java.util.Comparator comparator)Construct a SortedBag whose elements are to be ordered by the specified comparator. |
| Method Summary | |
|---|---|
boolean |
add(java.lang.Object o) |
boolean |
contains(java.lang.Object o) |
java.lang.Object |
first()Returns the first (lowest) element currently in this bag. |
protected java.util.Comparator |
getComparator()Return the Comparator used to order the bag contents. |
protected java.util.NavigableMap |
getInternalMap()Return the internal sorted-map holding the bag contents. |
protected java.util.concurrent.atomic.AtomicLong |
getNonceCounter()Return the nonce counter used to assign unique element ids. |
SortedBag |
headBag(java.lang.Object toElement)Returns a view of the portion of this bag whose elements are strictly less than toElement. |
protected java.util.NavigableMap |
instantiateInternalMap(java.util.Comparator comparator)Factory for the sorted internal map to use to hold the bag elements. |
boolean |
isEmpty() |
java.util.Iterator |
iterator() |
java.lang.Object |
last()Returns the last (highest) element currently in this bag. |
boolean |
remove(java.lang.Object o) |
java.lang.Object |
removeFirst()Remove and return the least element in this bag, or null if empty. |
java.lang.Object |
removeLast()Remove and return the greatest element in this bag, or null if empty. |
int |
size() |
SortedBag |
subBag(java.lang.Object fromElement, java.lang.Object toElement)Returns a view of the portion of this bag whose elements range from fromElement, inclusive, to toElement, exclusive. |
SortedBag |
tailBag(java.lang.Object fromElement)Returns a view of the portion of this bag whose elements are greater than or equal to fromElement. |
protected java.lang.Object |
unwrap(java.lang.Object o)Unwrap the specified element (which could be a wrapped or an "actual") element. |
protected SortedBag.UniqueElement |
wrap(java.lang.Object o)Wrap the specified element to ensure uniqueness. |
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, clear, containsAll, removeAll, retainAll, toArray, toArray, toString |
| Methods inherited from interface java.util.Collection |
|---|
equals, hashCode |
| Field Detail |
|---|
protected static final java.lang.Object NO_VALUE
protected java.util.concurrent.atomic.AtomicLong m_atomicNonce
protected java.util.NavigableMap m_map
protected java.util.Comparator m_comparator
| Constructor Detail |
|---|
protected SortedBag()
public SortedBag(java.util.Comparator comparator)
comparator - the comparator to use to order the elements| Method Detail |
|---|
protected java.util.NavigableMap getInternalMap()
protected java.util.Comparator getComparator()
protected java.util.concurrent.atomic.AtomicLong getNonceCounter()
public int size()
size in interface java.util.Collectionsize in class java.util.AbstractCollectionpublic boolean isEmpty()
isEmpty in interface java.util.CollectionisEmpty in class java.util.AbstractCollectionpublic boolean contains(java.lang.Object o)
contains in interface java.util.Collectioncontains in class java.util.AbstractCollectionpublic java.util.Iterator iterator()
iterator in interface java.lang.Iterableiterator in interface java.util.Collectioniterator in class java.util.AbstractCollectionpublic boolean add(java.lang.Object o)
add in interface java.util.Collectionadd in class java.util.AbstractCollectionpublic boolean remove(java.lang.Object o)
remove in interface java.util.Collectionremove in class java.util.AbstractCollection
public SortedBag subBag(java.lang.Object fromElement,
java.lang.Object toElement)
The returned bag will throw an IllegalArgumentException on an attempt to insert an element outside its range.
fromElement - low endpoint (inclusive) of the returned bagtoElement - high endpoint (exclusive) of the returned bagjava.lang.ClassCastException - if fromElement and toElement cannot be compared to one another using this bag's comparator (or, if the bag has no comparator, using natural ordering). Implementations may, but are not required to, throw this exception if fromElement or toElement cannot be compared to elements currently in the bag.java.lang.NullPointerException - if fromElement or toElement is null and this bag does not permit null elementsjava.lang.IllegalArgumentException - if fromElement is greater than toElement; or if this bag itself has a restricted range, and fromElement or toElement lies outside the bounds of the rangepublic SortedBag headBag(java.lang.Object toElement)
The returned bag will throw an IllegalArgumentException on an attempt to insert an element outside its range.
toElement - high endpoint (exclusive) of the returned bagjava.lang.ClassCastException - if toElement is not compatible with this bag's comparator (or, if the bag has no comparator, if toElement does not implement Comparable). Implementations may, but are not required to, throw this exception if toElement cannot be compared to elements currently in the bag.java.lang.NullPointerException - if toElement is null and this bag does not permit null elementsjava.lang.IllegalArgumentException - if this bag itself has a restricted range, and toElement lies outside the bounds of the rangepublic SortedBag tailBag(java.lang.Object fromElement)
The returned bag will throw an IllegalArgumentException on an attempt to insert an element outside its range.
fromElement - low endpoint (inclusive) of the returned bagjava.lang.ClassCastException - if fromElement is not compatible with this bag's comparator (or, if the bag has no comparator, if fromElement does not implement Comparable). Implementations may, but are not required to, throw this exception if fromElement cannot be compared to elements currently in the bag.java.lang.NullPointerException - if fromElement is null and this bag does not permit null elementsjava.lang.IllegalArgumentException - if this bag itself has a restricted range, and fromElement lies outside the bounds of the rangepublic java.lang.Object first()
NoSuchElementException - if this bag is emptypublic java.lang.Object last()
NoSuchElementException - if this bag is emptypublic java.lang.Object removeFirst()
public java.lang.Object removeLast()
protected java.util.NavigableMap instantiateInternalMap(java.util.Comparator comparator)
comparator - the comparator to use to sort the bag elementsprotected SortedBag.UniqueElement wrap(java.lang.Object o)
o - the element to wrapprotected java.lang.Object unwrap(java.lang.Object o)
wrapped or an "actual") element.o - the element to unwrap
|
Oracle® Fusion Middleware Java API Reference for Oracle Coherence 12c (12.1.3.0.0) E47890-01 |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||