rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWSet Class Reference
[RWCollectable-derived]

A group of unordered elements, not accessible by an external key, where duplicates are not allowed. More...

#include <rw/rwset.h>

Inheritance diagram for RWSet:
RWHashTable RWCollection RWCollectable RWFactory RWHashDictionary RWIdentitySet RWIdentityDictionary

List of all members.

Public Member Functions

virtual RWCollectablenewSpecies () const
virtual RWClassID isA () const
 RWSet (size_t n=RWCollection::DEFAULT_CAPACITY)
 RWSet (const RWSet &h)
 RWSet (RWSet &&h)
virtual ~RWSet ()
void operator= (const RWSet &h)
void operator= (RWSet &&h)
bool operator<= (const RWSet &h) const
bool operator<= (const RWHashTable &t) const
bool operator< (const RWSet &h) const
RWSetoperator*= (const RWSet &h)
void intersectWith (const RWSet &h, RWSet &ret) const
virtual void clearAndDestroy ()
virtual RWCollectableinsert (RWCollectable *c)
virtual bool isEqual (const RWCollectable *) const
virtual size_t occurrencesOf (const RWCollectable *target) const
virtual RWIteratornewIterator ()
virtual RWConstIteratornewConstIterator () const

Static Public Member Functions

static RWClassID classIsA ()

Detailed Description

Class RWSet represents a group of unordered elements, not accessible by an external key, where duplicates are not allowed. It corresponds to the Smalltalk class Set.

An object stored by RWSet must inherit from abstract base class RWCollectable, with suitable definition for virtual functions RWCollectable::hash() and RWCollectable::isEqual(). Use the function hash() to find objects with the same hash value, and then use isEqual() to confirm the match.

An item c is considered to be "already in the collection" if there is a member of the collection with the same hash value as c for which isEqual(c) returns true. In this case, method insert(c) will not add it, thus insuring that there are no duplicates.

The iterator for this class is RWSetIterator.

Synopsis

 typedef RWSet Set;   // Smalltalk typedef.
 #include <rw/rwset.h>
 RWSet h ;

Persistence

Polymorphic


Constructor & Destructor Documentation

RWSet::RWSet ( size_t  n = RWCollection::DEFAULT_CAPACITY  ) 

Constructs an empty set with n hashing buckets.

RWSet::RWSet ( const RWSet h  )  [inline]

Copy constructor. Makes a shallow copy of the collection h.

RWSet::RWSet ( RWSet &&  h  )  [inline]

Move constructor. The constructed RWSet takes ownership of the data owned by h.

Condition:
This method is only available on platforms with rvalue reference support.
virtual RWSet::~RWSet (  )  [virtual]

Calls clear(), inherited from RWHashTable.


Member Function Documentation

static RWClassID RWSet::classIsA (  )  [static]

Returns the RWClassID of this class.

Reimplemented from RWHashTable.

Reimplemented in RWHashDictionary, RWIdentityDictionary, and RWIdentitySet.

virtual void RWSet::clearAndDestroy (  )  [virtual]

Removes all objects from the collection and deletes them. Takes into account duplicate objects within a collection and only deletes them once. However, it does not take into account objects shared between different collections. Either do not use this function if you are sharing objects between separate collections, or put all collections that could be sharing objects into one single "super-collection" and call clearAndDestroy() on that.

Reimplemented from RWCollection.

Reimplemented in RWHashDictionary.

virtual RWCollectable* RWSet::insert ( RWCollectable c  )  [virtual]

Adds c to the collection and returns it. If an item is already in the collection which isEqual() to c, then the existing item is returned and the new item is not inserted.

Reimplemented from RWHashTable.

Reimplemented in RWHashDictionary, and RWIdentitySet.

void RWSet::intersectWith ( const RWSet h,
RWSet ret 
) const

Computes the intersection of self and h, and inserts the result into ret (which may be either empty or not, depending on the effect desired). This function may be slightly more efficient than operator*=().

virtual RWClassID RWSet::isA (  )  const [virtual]

Returns __RWSET, i.e. a class identifier, that identifies this object's class.

Reimplemented from RWHashTable.

Reimplemented in RWHashDictionary, RWIdentityDictionary, and RWIdentitySet.

virtual bool RWSet::isEqual ( const RWCollectable t  )  const [virtual]

Returns true if the collectable object "matches" the object at address t. The default definition is:

 return this == t;

i.e., both objects have the same address (a test for identity). The definition may be redefined in any consistent way.

Reimplemented from RWHashTable.

Reimplemented in RWHashDictionary, RWIdentityDictionary, and RWIdentitySet.

virtual RWConstIterator* RWSet::newConstIterator (  )  const [virtual]

Returns a const pointer to a dynamically allocated iterator for the collection.

Reimplemented from RWHashTable.

Reimplemented in RWHashDictionary.

virtual RWIterator* RWSet::newIterator (  )  [virtual]

Returns a dynamically allocated iterator for the collection.

Reimplemented from RWHashTable.

Reimplemented in RWHashDictionary.

virtual RWCollectable* RWSet::newSpecies (  )  const [virtual]

Allocates a new object off the heap of the same type as self and returns a pointer to it. You are responsible for deleting the object when done with it.

Reimplemented from RWHashTable.

Reimplemented in RWHashDictionary, RWIdentityDictionary, and RWIdentitySet.

virtual size_t RWSet::occurrencesOf ( const RWCollectable target  )  const [virtual]

Returns the count of entries that compare isEqual() to the item pointed to by target. Because duplicates are not allowed for this collection, only 0 or 1 can be returned.

Note:
If self is a collection of key-value pairs (e.g. RWHashDictionary), this method compares target with the keys in the collection.

Reimplemented from RWHashTable.

RWSet& RWSet::operator*= ( const RWSet h  ) 

Sets self to be the intersection of self and h. Returns self.

bool RWSet::operator< ( const RWSet h  )  const

Returns true if self is a proper subset of h, that is, every element of self has a counterpart in h which isEqual(), but where the two sets are not identical.

bool RWSet::operator<= ( const RWHashTable t  )  const

Returns true if self is a subset of t, that is, every element of self has a counterpart in t which isEqual().

Reimplemented from RWHashTable.

Reimplemented in RWFactory, RWHashDictionary, and RWIdentityDictionary.

bool RWSet::operator<= ( const RWSet h  )  const

Returns true if self is a subset of h, that is, every element of self has a counterpart in h which isEqual().

Reimplemented in RWFactory, RWHashDictionary, and RWIdentityDictionary.

void RWSet::operator= ( RWSet &&  h  )  [inline]

Move assignment. Self takes ownership of the data owned by h.

Condition:
This method is only available on platforms with rvalue reference support.
void RWSet::operator= ( const RWSet h  )  [inline]

Assignment operator. Makes a shallow copy of the collection h.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.