Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

13.5 Other Functions Shared by All RWCollections

There are several other functions that are shared by all classes that inherit from RWCollection. Note that these are not virtual functions.

13.5.1 Class Conversions

The following functions allow any collection class to be converted into an RWBag, RWSet, RWOrdered, or a SortedCollection (that is, an RWBinaryTree):

RWBag         asBag() const;
RWSet         asSet() const;
RWOrdered     asOrderedCollection() const;
RWBinaryTree  asSortedCollection() const

Note that since these functions mimic similar Smalltalk methods, they return a copy of the new collection by value. For large collections, this can be very expensive. Consider using operator+=() instead.

13.5.2 Inserting and Removing Other Collections

You can use these functions to respectively insert or remove the contents of their argument.

void  operator+=(const RWCollection&);
void  operator-=(const RWCollection&);

13.5.3 Selection

The function select():

typedef RWBoolean (*RWtestCollectable)(const RWCollectable*,
                   const void*);
RWCollection*     select(RWtestCollectable tst, void*);

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 of the same type as self and returns a pointer to it. This new collection is allocated off the heap, so you are responsible for deleting it when done.


Previous fileTop of documentContentsIndexNext file
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.