#include <coherence/util/SubSet.hpp>
Inherits AbstractSet.
Unlike DeltaSet, the SubSet is assumed to be a subset of the underlying set, and optimizes for both remove and retain operations.
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 | |||||||
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.
| |||||||
virtual bool | isEmpty () const | ||||||
Determine whether this collection contains any elements.
| |||||||
virtual bool | contains (Object::View v) const | ||||||
Determine if this collection contains the specified element.
| |||||||
virtual bool | containsAll (Collection::View vCol) const | ||||||
Determine if this collection contains all elements from the supplied collection.
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 | |||||||
virtual Iterator::Handle | iterator () const | ||||||
Return an Iterator over this collection.
| |||||||
virtual Muterator::Handle | iterator () | ||||||
Return 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 additional 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.
| |||||||
virtual bool | add (Object::Holder oh) | ||||||
Add the given element to this collection.
This implementation will throw a coherence::lang::UnsupportedOperationException | |||||||
virtual bool | addAll (Collection::View vCol) | ||||||
Add all elements from the supplied collection to this collection.
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.
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.
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.
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 Member Functions | |||||||
SubSet (Set::Holder hSet) | |||||||
Construct this set based on an existing set. | |||||||
SubSet (const SubSet &that) | |||||||
Copy constructor. | |||||||
virtual Set::Handle | instantiateModificationSet (size32_t cSize) const | ||||||
Instantiate a new modification set containing either removed or retained items. | |||||||
void | retainAllInternal (Collection::View vColOuter, Set::View vSetMatch, Set::View vSetExclude) | ||||||
Instantiate a new retained set with all elements in the specified collection that also exist in the specified set and are not excluded. | |||||||
Protected Attributes | |||||||
FinalHolder< Set > | f_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. |
SubSet | ( | Set::Holder | hSet | ) | [protected] |
Construct this set based on an existing set.
hSet | the set to base this subset on |
virtual Set::View getOriginal | ( | ) | const [virtual] |
virtual bool isModified | ( | ) | const [virtual] |
Determine if the set has been modified.
virtual bool isTrackingRetained | ( | ) | const [virtual] |
virtual Set::View getRetained | ( | ) | const [virtual] |
Determine what items were added to the subset.
Do not modify the returned set.
virtual bool isTrackingRemoved | ( | ) | const [virtual] |
virtual Set::View getRemoved | ( | ) | const [virtual] |
Determine what items were removed from the subset.
virtual Set::Handle instantiateModificationSet | ( | size32_t | cSize | ) | const [protected, virtual] |
Instantiate a new modification set containing either removed or retained items.
cSize | an initial size of the modification set |
virtual Set::Handle ensureRetained | ( | ) | [virtual] |
Get a mutable set of items that are retained in the subset.
virtual Set::Handle ensureRemoved | ( | ) | [virtual] |
Get a mutable set of items that are removed in the subset.
void retainAllInternal | ( | Collection::View | vColOuter, | |
Set::View | vSetMatch, | |||
Set::View | vSetExclude | |||
) | [protected] |
Instantiate a new retained set with all elements in the specified collection that also exist in the specified set and are not excluded.
vColOuter | collection to iterate | |
vSetMatch | set to test the presence for each iterated element | |
vSetExclude | optional set of excluded elements |