A group of unordered elements, not accessible by an external key, where duplicates are not allowed. More...
#include <rw/rwset.h>
Public Member Functions | |
RWSet () | |
RWSet (size_t n) | |
RWSet (const RWSet &h) | |
RWSet (RWSet &&h) | |
virtual | ~RWSet () |
virtual void | clearAndDestroy () |
virtual RWCollectable * | copy () const |
virtual RWCollectable * | insert (RWCollectable *c) |
void | intersectWith (const RWSet &h, RWSet &ret) const |
virtual RWClassID | isA () const |
virtual bool | isEqual (const RWCollectable *) const |
virtual RWConstIterator * | newConstIterator () const |
virtual RWIterator * | newIterator () |
virtual RWCollectable * | newSpecies () const |
virtual size_t | occurrencesOf (const RWCollectable *target) const |
RWSet & | operator*= (const RWSet &h) |
bool | operator< (const RWSet &h) const |
bool | operator<= (const RWSet &h) const |
RWSet & | operator= (const RWSet &h) |
RWSet & | operator= (RWSet &&h) |
Public Member Functions inherited from RWHashTable | |
RWHashTable () | |
RWHashTable (size_t N) | |
RWHashTable (const RWHashTable &t) | |
RWHashTable (RWHashTable &&t) | |
virtual void | apply (RWapplyCollectable ap, void *) |
virtual void | clear () |
virtual size_t | entries () const |
virtual RWCollectable * | find (const RWCollectable *) const |
virtual bool | isEmpty () const |
bool | operator!= (const RWHashTable &) const |
bool | operator<= (const RWHashTable &t) const |
RWHashTable & | operator= (const RWHashTable &t) |
RWHashTable & | operator= (RWHashTable &&t) |
bool | operator== (const RWHashTable &t) const |
virtual RWCollectable * | remove (const RWCollectable *) |
virtual void | resize (size_t n=0) |
void | swap (RWHashTable &t) |
Public Member Functions inherited from RWCollection | |
virtual | ~RWCollection () |
RWBag | asBag () const |
RWBinaryTree | asBinaryTree () const |
RWOrdered | asOrderedCollection () const |
RWSet | asSet () const |
RWBinaryTree | asSortedCollection () const |
virtual RWspace | binaryStoreSize () const |
virtual bool | contains (const RWCollectable *target) const |
void | operator+= (const RWCollection &c) |
void | operator-= (const RWCollection &c) |
virtual void | removeAndDestroy (const RWCollectable *target) |
virtual void | restoreGuts (RWvistream &) |
virtual void | restoreGuts (RWFile &) |
virtual void | saveGuts (RWvostream &) const |
virtual void | saveGuts (RWFile &) const |
RWCollection * | select (RWtestCollectable tst, void *vp) const |
Public Member Functions inherited from RWCollectable | |
virtual | ~RWCollectable () |
virtual int | compareTo (const RWCollectable *) const |
virtual unsigned | hash () const |
RWspace | recursiveStoreSize () const |
RWStringID | stringID () const |
Additional Inherited Members | |
Static Public Member Functions inherited from RWCollectable | |
static RWClassID | classID (const RWStringID &name) |
static RWClassID | classIsA () |
static bool | isAtom (RWClassID id) |
static RWspace | nilStoreSize () |
Static Public Attributes inherited from RWCollection | |
static size_t | DEFAULT_CAPACITY |
Related Functions inherited from RWCollection | |
typedef void(* | RWapplyCollectable) (RWCollectable *, void *) |
typedef bool(* | RWtestCollectable) (const RWCollectable *, const void *) |
typedef bool(* | RWtestCollectablePair) (const RWCollectable *, const RWCollectable *, const void *) |
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.
RWSet::RWSet | ( | ) |
Constructs an empty set with RWCollection::DEFAULT_CAPACITY hashing buckets.
RWSet::RWSet | ( | size_t | n | ) |
Constructs an empty set with n hashing buckets.
|
inline |
Copy constructor. Makes a shallow copy of the collection h.
|
inline |
Move constructor. The constructed RWSet takes ownership of the data owned by h.
|
virtual |
Calls clear(), inherited from RWHashTable.
|
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 |
Returns a new, copy-constructed object of the same type as self. The caller is responsible for deleting the object.
Reimplemented from RWHashTable.
Reimplemented in RWIdentitySet, RWIdentityDictionary, and RWHashDictionary.
|
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.
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 |
Returns __RWSET
, i.e. a class identifier, that identifies this object's class.
Reimplemented from RWHashTable.
Reimplemented in RWIdentitySet, RWIdentityDictionary, and RWHashDictionary.
|
virtual |
Behaves as if compareTo(t) was invoked, returning true
if the result equals 0, false
otherwise.
Reimplemented from RWHashTable.
Reimplemented in RWHashDictionary, RWIdentityDictionary, and RWIdentitySet.
|
virtual |
Returns a const pointer to a dynamically allocated iterator for the collection.
Reimplemented from RWHashTable.
Reimplemented in RWHashDictionary.
|
virtual |
Returns a dynamically allocated iterator for the collection.
Reimplemented from RWHashTable.
Reimplemented in RWHashDictionary.
|
virtual |
Returns a new, default-constructed object of the same type as self. The caller is responsible for deleting the object.
Reimplemented from RWHashTable.
Reimplemented in RWIdentitySet, RWIdentityDictionary, and RWHashDictionary.
|
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.
Reimplemented from RWHashTable.
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 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().
Assignment operator. Makes a shallow copy of the collection h.
Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |