SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Contains virtual functions for inserting and retrieving pointers to RWCollectable objects into the collection classes. More...
#include <rw/colclass.h>
Public Member Functions | |
virtual | ~RWCollection () |
virtual void | apply (RWapplyCollectable ap, void *vp)=0 |
RWBag | asBag () const |
RWBinaryTree | asBinaryTree () const |
RWOrdered | asOrderedCollection () const |
RWSet | asSet () const |
RWBinaryTree | asSortedCollection () const |
virtual RWspace | binaryStoreSize () const |
virtual void | clear ()=0 |
virtual void | clearAndDestroy () |
virtual bool | contains (const RWCollectable *target) const |
virtual size_t | entries () const =0 |
virtual RWCollectable * | find (const RWCollectable *target) const =0 |
virtual RWCollectable * | insert (RWCollectable *c)=0 |
virtual RWClassID | isA () const |
virtual bool | isEmpty () const =0 |
virtual RWConstIterator * | newConstIterator () const =0 |
virtual RWIterator * | newIterator ()=0 |
virtual size_t | occurrencesOf (const RWCollectable *t) const =0 |
void | operator+= (const RWCollection &c) |
void | operator-= (const RWCollection &c) |
virtual RWCollectable * | remove (const RWCollectable *target)=0 |
virtual void | removeAndDestroy (const RWCollectable *target) |
virtual void | restoreGuts (RWFile &) |
virtual void | restoreGuts (RWvistream &) |
virtual void | saveGuts (RWFile &) const |
virtual void | saveGuts (RWvostream &) const |
RWCollection * | select (RWtestCollectable tst, void *vp) const |
Public Member Functions inherited from RWCollectable | |
virtual | ~RWCollectable () |
virtual int | compareTo (const RWCollectable *) const |
virtual RWCollectable * | copy () const |
virtual unsigned | hash () const |
virtual bool | isEqual (const RWCollectable *t) const |
virtual RWCollectable * | newSpecies () const |
RWspace | recursiveStoreSize () const |
RWStringID | stringID () const |
Static Public Attributes | |
static size_t | DEFAULT_CAPACITY |
Related Symbols | |
(Note that these are not member symbols.) | |
typedef void(* | RWapplyCollectable) (RWCollectable *, void *) |
typedef bool(* | RWtestCollectable) (const RWCollectable *, const void *) |
typedef bool(* | RWtestCollectablePair) (const RWCollectable *, const RWCollectable *, const void *) |
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 () |
Class RWCollection is an abstract base class for the Smalltalk-like collection classes. The class contains virtual functions for inserting and retrieving pointers to RWCollectable objects into the collection classes. Virtual functions are also provided for storing and reading the collections to files and streams. Collections that inherit this base class typically redefine one or more of these functions.
Several of the methods of this class are abstract. These functions must be defined in derived classes. For these functions the description is intended to be generic – all inheriting collection classes generally follow the described pattern. Exceptions are noted in the documentation for the particular class.
For many other functions, a suitable definition is provided by RWCollection and a deriving class may not need to redefine the function. Examples are contains() or restoreGuts().
|
virtual |
Empty destructor.
|
pure virtual |
This function applies the user-supplied function pointed to by ap to each member of the collection. This function should have the following prototype:
The function yourApplyFunction()
can perform any operation on the item at address ctp
that does not change the hash value or sorting order of the item. Client data may be passed to this function through the second argument vp.
Implemented in RWBag, RWBinaryTree, RWBTree, RWDlistCollectables, RWHashTable, RWOrdered, RWSequenceable, and RWSlistCollectables.
RWBag RWCollection::asBag | ( | ) | const |
Allows any collection to be converted to an RWBag. The return value is a copy of the data. This can be very expensive for large collections. You should consider using operator+=() to insert each item from this collection into a collection of your choice.
RWBinaryTree RWCollection::asBinaryTree | ( | ) | const |
Allows any collection to be converted to an RWBinaryTree. The return value is a copy of the data. This can be very expensive for large collections. You should consider using operator+=() to insert each item from this collection into a collection of your choice.
RWOrdered RWCollection::asOrderedCollection | ( | ) | const |
Allows any collection to be converted to an RWOrdered. The return value is a copy of the data. This can be very expensive for large collections. You should consider using operator+=() to insert each item from this collection into a collection of your choice.
RWSet RWCollection::asSet | ( | ) | const |
Allows any collection to be converted to an RWSet. The return value is a copy of the data. This can be very expensive for large collections. You should consider using operator+=() to insert each item from this collection into a collection of your choice.
RWBinaryTree RWCollection::asSortedCollection | ( | ) | const |
Allows any collection to be converted to an RWBinaryTree. The return value is a copy of the data. This can be very expensive for large collections. You should consider using operator+=() to insert each item from this collection into a collection of your choice.
|
virtual |
Returns the number of bytes used by the virtual function saveGuts(RWFile&) to store an object. Typically, this involves adding up the space required to store all primitives, plus the results of calling recursiveStoreSize() for all objects inheriting from RWCollectable. See the Essential Tools Module User's Guide for details.
Reimplemented from RWCollectable.
|
pure virtual |
Removes all objects from the collection. Does not delete the objects themselves.
Implemented in RWBag, RWBinaryTree, RWBTree, RWBTreeDictionary, RWDlistCollectables, RWHashDictionary, RWHashTable, RWOrdered, RWSequenceable, and RWSlistCollectables.
|
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 in RWBag, RWBTreeDictionary, RWHashDictionary, and RWSet.
|
virtual |
Returns true
if the collection contains an item where the virtual function find() returns non-nil.
Reimplemented in RWDlistCollectables, and RWSlistCollectables.
|
pure virtual |
Returns the total number of items in the collection.
Implemented in RWBag, RWBinaryTree, RWBTree, RWDlistCollectables, RWHashTable, RWOrdered, RWSequenceable, and RWSlistCollectables.
|
pure virtual |
Returns a pointer to the first item in the collection which "matches" the object pointed to by target or rwnil if no item was found. For most collections, an item "matches" the target if either isEqual() or compareTo() find equivalence, whichever is appropriate for the actual collection type. However, the "identity collections" (i.e., RWIdentitySet and RWIdentityDictionary) look for an item with the same address (i.e., "is identical to").
Implemented in RWBag, RWBinaryTree, RWBTree, RWBTreeDictionary, RWDlistCollectables, RWHashDictionary, RWHashTable, RWIdentitySet, RWOrdered, RWSequenceable, and RWSlistCollectables.
|
pure virtual |
Adds an item to the collection and returns a pointer to it. If the item is already in the collection, some collections derived from RWCollection return the old instance, others return rwnil.
Implemented in RWBag, RWBinaryTree, RWBTree, RWBTreeDictionary, RWDlistCollectables, RWHashDictionary, RWHashTable, RWIdentitySet, RWOrdered, RWSequenceable, RWSet, RWSlistCollectables, RWSlistCollectablesStack, and RWSortedVector.
|
inlinevirtual |
Returns __RWCOLLECTION
Reimplemented from RWCollectable.
Reimplemented in RWBag, RWBinaryTree, RWBTree, RWBTreeDictionary, RWDlistCollectables, RWHashDictionary, RWHashTable, RWIdentityDictionary, RWIdentitySet, RWOrdered, RWSet, RWSlistCollectables, RWSlistCollectablesQueue, RWSlistCollectablesStack, and RWSortedVector.
|
pure virtual |
Returns true
if the collection is empty, otherwise returns false
.
Implemented in RWBag, RWBinaryTree, RWBTree, RWDlistCollectables, RWHashTable, RWOrdered, RWSequenceable, and RWSlistCollectables.
|
pure virtual |
Returns a const pointer to a dynamically allocated iterator for the collection.
Implemented in RWBag, RWBinaryTree, RWBTree, RWDlistCollectables, RWHashDictionary, RWHashTable, RWOrdered, RWSet, and RWSlistCollectables.
|
pure virtual |
Returns a dynamically allocated iterator for the collection.
Implemented in RWBag, RWBinaryTree, RWBTree, RWDlistCollectables, RWHashDictionary, RWHashTable, RWOrdered, RWSet, and RWSlistCollectables.
|
pure virtual |
Returns the number of items in the collection which are "matches" for t. See function find() for a definition of matches.
Implemented in RWBag, RWBinaryTree, RWBTree, RWDlistCollectables, RWHashTable, RWOrdered, RWSequenceable, RWSet, RWSlistCollectables, and RWSortedVector.
void RWCollection::operator+= | ( | const RWCollection & | c | ) |
Adds each item in c to self.
void RWCollection::operator-= | ( | const RWCollection & | c | ) |
Removes each item in c from self.
|
pure virtual |
Removes and returns a pointer to the first item in the collection which "matches" the object pointed to by target. Returns nil
if no object was found. Does not delete the object. See function find() for a definition of matches.
Implemented in RWBag, RWBinaryTree, RWBTree, RWBTreeDictionary, RWDlistCollectables, RWHashDictionary, RWHashTable, RWIdentitySet, RWOrdered, RWSequenceable, RWSlistCollectables, RWSlistCollectablesQueue, and RWSlistCollectablesStack.
|
virtual |
Removes and deletes the first item in the collection which "matches" the object pointed to by target.
Reimplemented in RWBag, RWBTreeDictionary, RWHashDictionary, RWSlistCollectablesQueue, and RWSlistCollectablesStack.
|
virtual |
Repeatedly calls the global operator:
followed by insert(RWCollectable*) for each item in the collection.
Reimplemented from RWCollectable.
Reimplemented in RWBTreeDictionary, RWHashDictionary, and RWSlistCollectablesStack.
|
virtual |
Repeatedly calls the global operator:
followed by insert(RWCollectable*) for each item in the collection.
Reimplemented from RWCollectable.
Reimplemented in RWBTreeDictionary, RWHashDictionary, and RWSlistCollectablesStack.
|
virtual |
Calls the global operator:
for each object in the collection.
Reimplemented from RWCollectable.
Reimplemented in RWBinaryTree.
|
virtual |
Calls the global operator.
for each object in the collection.
Reimplemented from RWCollectable.
Reimplemented in RWBinaryTree.
RWCollection * RWCollection::select | ( | RWtestCollectable | tst, |
void * | vp ) const |
Evaluates the function pointed to by tst for each item in the collection. It inserts those items for which the function returns true
into a new collection allocated off the heap of the same type as self and returns a pointer to this new collection. Because the new collection is allocated off the heap, you are responsible for deleting it when done. This is not a virtual function.
|
related |
A global function used by the apply() method in RWCollection classes to apply a user defined action to an RWCollectable object. A applyCollectable function has prototype:
|
related |
A global function used by the select() method in RWCollection classes to test an RWCollectable object for a user defined property. A testCollectable function has prototype:
|
related |
A global function used by the select() method in RWCollection classes to test a pair of RWCollectable objects for a user defined property. A testCollectablePair function has prototype:
|
static |
The default number of buckets in a RWCollection class.
Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |