Oracle Coherence for C++ API
Release 3.7.1.0

E22845-01

SubSet Class Reference

#include <coherence/util/SubSet.hpp>

Inherits AbstractSet.

List of all members.


Detailed Description

Implements a set which is based on another set, which is assumed to be immutable.

Unlike DeltaSet, the SubSet is assumed to be a subset of the underlying set, and optimizes for both remove and retain operations.

Author:
tb 2009.02.10
 

Public Types

typedef spec::Handle  Handle
  SubSet Handle definition.
typedef spec::View  View
  SubSet View definition.
typedef spec::Holder  Holder
  SubSet Holder definition.

Public Member Functions

  SubSet (const SubSet &that)
  Copy constructor.
virtual Set::View  getOriginal () const
  Determine what items were in the original set.
virtual bool  isModified () const
  Determine if the set has been modified.
virtual bool  isTrackingRetained () const
  Determine if the SubSet is tracking retained items versus removed items.
virtual Set::View  getRetained () const
  Determine what items were added to the subset.
virtual bool  isTrackingRemoved () const
  Determine if the SubSet is tracking removed items versus retained items.
virtual Set::View  getRemoved () const
  Determine what items were removed from the subset.
virtual Set::Handle  ensureRetained ()
  Get a mutable set of items that are retained in the subset.
virtual Set::Handle  ensureRemoved ()
  Get a mutable set of items that are removed in the subset.
virtual void  resolve ()
  Apply the changes to the underlying set ("commit").
virtual void  reset ()
  Discard the changes to the set ("rollback").
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 v) 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 bool  containsAll (Collection::View vCol) const
  Determine if this collection contains all elements from the supplied collection.
Parameters:
  vCol  the collection of elements to test for containment
Returns:
true iff this collection contains all elements from the supplied collection
Exceptions:
  coherence::lang::NullPointerException  if the specified collection is NULL
See also:
contains()

This implementation iterates over the specified collection, checking each element returned by the iterator in turn to see if it's contained in this collection. If all elements are so contained true is returned, otherwise false.

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
ObjectArray::Handle 
toArray (ObjectArray::Handle hao=NULL) const
  Return the contents of this collection as an ObjectArray.

If the collection fits in the specified array, it is returned, otherwise, a new array is allocated that is the size of this collection.

If this collection fits in the array with aditional room then the element in the array immediately following the end of the collection is set to NULL. This can be useful in determining the length of this collection if the caller knows that the collection does not contain any NULL elements.

Parameters:
  hao  an array in which to store the collection's contents
Returns:
a ObjectArray containing all the elements of the collection in the same order as returned by the collection's Iterator
See also:
Iterator
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  addAll (Collection::View vCol)
  Add all elements from the supplied collection to this collection.
Parameters:
  vCol  the collection of elements to add
Returns:
true iff this collection was modified as a result of this operation
Exceptions:
  coherence::lang::NullPointerException  if the specified collection is NULL
See also:
add()

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

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 bool  removeAll (Collection::View vCol)
  Remove all instances of the elements in the supplied collection from this collection.

Upon completion, contains() on this collection will return false for all elements in the supplied collection.

Parameters:
  vCol  the collection of elements to remove
Returns:
true iff this collection was modified as a result of this operation
Exceptions:
  coherence::lang::NullPointerException  if the specified collection is NULL
See also:
remove()

contains()

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

virtual bool  retainAll (Collection::View vCol)
  Remove all elements from this collection that are not present in the supplied collection.
Parameters:
  vCol  the collection of elements to retain
Returns:
true iff this collection was modified as a result of this operation.
Exceptions:
  coherence::lang::NullPointerException  if the specified collection is NULL
See also:
remove()

contains()

This implementation will throw a coherence::lang::UnsupportedOperationException unless remove() is overridden (assuming there are items to be removed by the operation).

virtual void  clear ()
  Remove all elements from this collection.

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


Protected Attributes

FinalHolder< Set m_ohSetOrig
  The underlying set (assumed immutable).
MemberHandle< Set m_hSetMod
  The removed or retained items.
bool  m_fRetained
  Toggles between whether the modifications are removed or retained.

Member Function Documentation

virtual Set::View getOriginal (    )  const [virtual]

Determine what items were in the original set.

Returns:
the set used to construct this SubSet

virtual bool isModified (    )  const [virtual]

Determine if the set has been modified.

Returns:
true if any items have been removed

virtual bool isTrackingRetained (    )  const [virtual]

Determine if the SubSet is tracking retained items versus removed items.

Returns:
true if the SubSet is tracking just the retained items, false if the SubSet is tracking just the removed items

virtual Set::View getRetained (    )  const [virtual]

Determine what items were added to the subset.

Do not modify the returned set.

Returns:
a set of retained items

virtual bool isTrackingRemoved (    )  const [virtual]

Determine if the SubSet is tracking removed items versus retained items.

Returns:
true if the SubSet is tracking just the removed items, false if the SubSet is tracking just the retained items

virtual Set::View getRemoved (    )  const [virtual]

Determine what items were removed from the subset.

Returns:
an immutable set of removed items

virtual Set::Handle ensureRetained (    )  [virtual]

Get a mutable set of items that are retained in the subset.

Returns:
a mutable set of retained items

virtual Set::Handle ensureRemoved (    )  [virtual]

Get a mutable set of items that are removed in the subset.

Returns:
a mutable set of removed items

The documentation for this class was generated from the following file:

Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.