Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.2.1.3.0)

E80355-01

SortedBag Class Reference

#include <coherence/util/SortedBag.hpp>

Inherits AbstractCollection.

Inherited by TopNAggregator::PartialResult, and SortedBag::ViewBag.

List of all members.


Detailed Description

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.

Author:
rhl 2013.04.24

Public Types

typedef spec::Handle Handle
 SortedBag Handle definition.
typedef spec::View View
 SortedBag View definition.
typedef spec::Holder Holder
 SortedBag Holder definition.
typedef this_spec::Handle Handle
 AbstractCollection Handle definition.
typedef this_spec::View View
 AbstractCollection View definition.
typedef this_spec::Holder Holder
 AbstractCollection Holder definition.

Public Member Functions

virtual size32_t size () const
 Return the number of elements in this collection.

Returns:
the number of elements in this collection

virtual bool isEmpty () const
 Determine whether this collection contains any elements.

Returns:
true if this collection has no elements

virtual bool contains (Object::View vo) const
 Determine if this collection contains the specified element.

Parameters:
v the element to test for containment
Returns:
true iff this collection contains the given element

virtual Iterator::Handle iterator () const
 Return an Iterator over this collection.

Returns:
an Iterator over this collection

virtual Muterator::Handle iterator ()
 Return an Iterator over this collection.

Returns:
an Iterator over this collection

virtual bool add (Object::Holder oh)
 Add the given element to this collection.

Parameters:
oh the element to add
Returns:
true iff this collection was modified as a result of this operation

This implementation will throw a coherence::lang::UnsupportedOperationException

virtual bool remove (Object::View v)
 Remove the supplied element from this collection.

Parameters:
v the element to remove
Returns:
true iff this collection was modified as a result of this operation

This implementation will throw a coherence::lang::UnsupportedOperationException unless add() is overridden (assuming the specified collection is non-empty).

virtual SortedBag::Handle subBag (Object::View vFrom, Object::View vTo)
 Returns a view of the portion of this bag whose elements range from vFrom, inclusive, to vTo, exclusive.
virtual SortedBag::Handle headBag (Object::View vTo)
 Returns a view of the portion of this bag whose elements are strictly less than vTo.
virtual SortedBag::Handle tailBag (Object::View vFrom)
 Returns a view of the portion of this bag whose elements are greater than or equal to vFrom.
virtual Object::Holder first () const
 Returns the first (lowest) element currently in this bag.
virtual Object::Holder last () const
 Returns the last (highest) element currently in this bag.
virtual Object::Holder removeFirst ()
 Remove and return the least element in this bag, or NULL if empty.
virtual Object::Holder removeLast ()
 Remove and return the greatest element in this bag, or NULL if empty.
virtual Object::Holder unwrap (Object::View v) const
 Unwrap the specified element (which could be a wrapped or an "actual") element.

Protected Member Functions

 SortedBag ()
 Default constructor.
 SortedBag (Comparator::View vComparator)
 Construct a SortedBag whose elements are to be ordered by the specified comparator.
virtual
NavigableMap::Handle 
getInternalMap () const
 Return the internal navigable map holding the bag contents.
virtual Comparator::View getComparator () const
 Return the Comparator used to order the bag contents.
virtual
AtomicCounter::Handle 
getNonceCounter ()
 Return the nonce counter used to assign unique element ids.
virtual
NavigableMap::Handle 
instantiateInternalMap (Comparator::View vComparator)
 Factory for the navigable internal map to use to hold the bag elements.
virtual
UniqueElement::View 
wrap (Object::Holder oh)
 Wrap the specified element to ensure uniqueness.

Protected Attributes

MemberHandle
< AtomicCounter
m_hAtomicNonce
 The nonce used to increment the unique element ids.
MemberView< Comparatorm_vComparator
 The comparator used to compare logical elements.
MemberHandle
< NavigableMap
m_hMap
 The internal navigable map holding the bag contents.

Classes

class  UniqueElement
 UniqueElement represents a unique instance of a logical element in the bag. More...
class  ViewBag
 A range-limited view of the SortedBag. More...
class  WrapperComparator
 WrapperComparator is a Comparator implementation that is aware of UniqueElement wrappers and will delegate the comparison of the elements in both forms to the wrapped comparator. More...

Constructor & Destructor Documentation

SortedBag ( Comparator::View  vComparator  )  [protected]

Construct a SortedBag whose elements are to be ordered by the specified comparator.

Parameters:
vComparator the comparator to use to order the elements


Member Function Documentation

virtual NavigableMap::Handle getInternalMap (  )  const [protected, virtual]

Return the internal navigable map holding the bag contents.

Returns:
the internal navigable map holding the bag contents

virtual Comparator::View getComparator (  )  const [protected, virtual]

Return the Comparator used to order the bag contents.

Returns:
the Comparator used to order the bag contents

virtual AtomicCounter::Handle getNonceCounter (  )  [protected, virtual]

Return the nonce counter used to assign unique element ids.

Returns:
the nonce counter

virtual SortedBag::Handle subBag ( Object::View  vFrom,
Object::View  vTo 
) [virtual]

Returns a view of the portion of this bag whose elements range from vFrom, inclusive, to vTo, exclusive.

(If vFrom and vTo are equal, the returned bag is empty.) The returned bag is backed by this bag, so changes in the returned bag are reflected in this bag, and vice-versa. The returned bag supports all optional bag operations that this bag supports.

The returned bag will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters:
vFrom low endpoint (inclusive) of the returned bag
vTo high endpoint (exclusive) of the returned bag
Returns:
a view of the portion of this bag whose elements range from vFrom, inclusive, to vTo, exclusive
Exceptions:
ClassCastException if vFrom and vTo 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 vFrom or vTo cannot be compared to elements currently in the bag.
NullPointerException if vFrom or vTo is NULL and this bag does not permit NULL elements
IllegalArgumentException if vFrom is greater than vTo; or if this bag itself has a restricted range, and vFrom or vTo lies outside the bounds of the range

Reimplemented in SortedBag::ViewBag.

virtual SortedBag::Handle headBag ( Object::View  vTo  )  [virtual]

Returns a view of the portion of this bag whose elements are strictly less than vTo.

The returned bag is backed by this bag, so changes in the returned bag are reflected in this bag, and vice-versa. The returned bag supports all optional bag operations that this bag supports.

The returned bag will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters:
vTo high endpoint (exclusive) of the returned bag
Returns:
a view of the portion of this bag whose elements are strictly less than vTo
Exceptions:
ClassCastException if vTo is not compatible with this bag's comparator (or, if the bag has no comparator, if vTo does not implement Comparable). Implementations may, but are not required to, throw this exception if vTo cannot be compared to elements currently in the bag.
NullPointerException if vTo is NULL and this bag does not permit NULL elements
IllegalArgumentException if this bag itself has a restricted range, and vTo lies outside the bounds of the range

Reimplemented in SortedBag::ViewBag.

virtual SortedBag::Handle tailBag ( Object::View  vFrom  )  [virtual]

Returns a view of the portion of this bag whose elements are greater than or equal to vFrom.

The returned bag is backed by this bag, so changes in the returned bag are reflected in this bag, and vice-versa. The returned bag supports all optional bag operations that this bag supports.

The returned bag will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters:
vFrom low endpoint (inclusive) of the returned bag
Returns:
a view of the portion of this bag whose elements are greater than or equal to vFrom
Exceptions:
ClassCastException if vFrom is not compatible with this bag's comparator (or, if the bag has no comparator, if vFrom does not implement Comparable). Implementations may, but are not required to, throw this exception if vFrom cannot be compared to elements currently in the bag.
NullPointerException if vFrom is NULL and this bag does not permit NULL elements
IllegalArgumentException if this bag itself has a restricted range, and vFrom lies outside the bounds of the range

Reimplemented in SortedBag::ViewBag.

virtual Object::Holder first (  )  const [virtual]

Returns the first (lowest) element currently in this bag.

Returns:
the first (lowest) element currently in this bag
Exceptions:
NoSuchElementException if this bag is empty

virtual Object::Holder last (  )  const [virtual]

Returns the last (highest) element currently in this bag.

Returns:
the last (highest) element currently in this bag
Exceptions:
NoSuchElementException if this bag is empty

virtual Object::Holder removeFirst (  )  [virtual]

Remove and return the least element in this bag, or NULL if empty.

Returns:
the removed first element of this bag, or NULL if empty

virtual Object::Holder removeLast (  )  [virtual]

Remove and return the greatest element in this bag, or NULL if empty.

Returns:
the removed last element of this bag, or NULL if empty

virtual Object::Holder unwrap ( Object::View  v  )  const [virtual]

Unwrap the specified element (which could be a wrapped or an "actual") element.

Parameters:
o the element to unwrap
Returns:
the unwrapped element

virtual NavigableMap::Handle instantiateInternalMap ( Comparator::View  vComparator  )  [protected, virtual]

Factory for the navigable internal map to use to hold the bag elements.

Parameters:
comparator the comparator to use to sort the bag elements
Returns:
a navigable map

virtual UniqueElement::View wrap ( Object::Holder  oh  )  [protected, virtual]

Wrap the specified element to ensure uniqueness.

Parameters:
oh the element to wrap
Returns:
a unique element representing the specified element


The documentation for this class was generated from the following file:
Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.