rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWSlistCollectables Class Reference
[RWCollectable-derived]

Represents a group of ordered elements without keyed access, where duplicates are allowed. More...

#include <rw/slistcol.h>

Inheritance diagram for RWSlistCollectables:
RWSequenceable RWCollection RWCollectable RWSlistCollectablesQueue RWSlistCollectablesStack

List of all members.

Public Member Functions

virtual RWCollectablenewSpecies () const
virtual RWClassID isA () const
 RWSlistCollectables ()
 RWSlistCollectables (RWCollectable *a)
bool operator== (const RWSlistCollectables &s) const
virtual RWCollectableappend (RWCollectable *a)
virtual void apply (RWapplyCollectable ap, void *x)
virtual RWCollectable *& at (size_t i)
virtual const RWCollectableat (size_t i) const
virtual void clear ()
virtual bool contains (const RWCollectable *target) const
virtual size_t entries () const
virtual RWCollectablefind (const RWCollectable *target) const
virtual RWCollectablefirst () const
virtual size_t index (const RWCollectable *c) const
virtual RWCollectableinsert (RWCollectable *a)
virtual RWCollectableinsertAt (size_t indx, RWCollectable *e)
virtual bool isEmpty () const
virtual bool isEqual (const RWCollectable *) const
virtual RWCollectablelast () const
virtual size_t occurrencesOf (const RWCollectable *target) const
virtual RWCollectableprepend (RWCollectable *a)
virtual RWCollectableremove (const RWCollectable *target)
virtual RWIteratornewIterator ()
virtual RWConstIteratornewConstIterator () const
bool containsReference (const RWCollectable *e) const
RWCollectablefindReference (const RWCollectable *e) const
RWCollectableget ()
size_t occurrencesOfReference (const RWCollectable *e) const
RWCollectableremoveReference (const RWCollectable *e)

Static Public Member Functions

static RWClassID classIsA ()

Detailed Description

Class RWSlistCollectables represents a group of ordered elements, without keyed access. Duplicates are allowed. The ordering of elements is determined externally, by the order of insertion and removal. An object stored by RWSlistCollectables must inherit from abstract base class RWCollectable.

You must use the virtual function isEqual() (see class RWCollectable) to find a match between a target and an item in the collection.

Class RWSlistCollectables is implemented as a singly-linked list, which allows for efficient insertion and removal, but efficient movement in only one direction. This class corresponds to the Smalltalk class LinkedList.

Synopsis

 // Smalltalk typedef:
 typedef RWSlistCollectables LinkedList ;
 #include <rw/slistcol.h>
 RWSlistCollectables a;

Persistence

Polymorphic


Constructor & Destructor Documentation

RWSlistCollectables::RWSlistCollectables (  ) 

Constructs an empty linked list.

RWSlistCollectables::RWSlistCollectables ( RWCollectable a  )  [inline]

Constructs a linked list with single item a.


Member Function Documentation

virtual RWCollectable* RWSlistCollectables::append ( RWCollectable a  )  [inline, virtual]

Adds a to the end of the collection and returns it. Returns rwnil if the insertion was unsuccessful.

Implements RWSequenceable.

Reimplemented in RWSlistCollectablesStack.

virtual void RWSlistCollectables::apply ( RWapplyCollectable  ap,
void *  x 
) [inline, virtual]

This function has been redefined to apply the user-defined function pointed to by ap to each member of the collection, in order from first to last.

Implements RWSequenceable.

virtual const RWCollectable* RWSlistCollectables::at ( size_t  i  )  const [inline, virtual]

The index i must be between 0 and the number of items in the collection less one, or an exception of type RWBoundsErr is thrown.

Note:
For a linked list, these functions must traverse all the links, decreasing their efficiency.

Implements RWSequenceable.

virtual RWCollectable*& RWSlistCollectables::at ( size_t  i  )  [inline, virtual]

The index i must be between 0 and the number of items in the collection less one, or an exception of type RWBoundsErr is thrown.

Note:
For a linked list, these functions must traverse all the links, decreasing their efficiency.

Implements RWSequenceable.

static RWClassID RWSlistCollectables::classIsA (  )  [static]

Returns the RWClassID of this class.

Reimplemented from RWCollectable.

Reimplemented in RWSlistCollectablesQueue, and RWSlistCollectablesStack.

virtual void RWSlistCollectables::clear (  )  [inline, virtual]

Removes all objects from the collection. Does not delete the objects themselves.

Implements RWSequenceable.

virtual bool RWSlistCollectables::contains ( const RWCollectable target  )  const [inline, virtual]

Returns true if the collection contains an item where the virtual function find() returns non-nil.

Reimplemented from RWCollection.

bool RWSlistCollectables::containsReference ( const RWCollectable e  )  const [inline]

Returns true if the list contains an item that is identical to the item pointed to by e (that is, that has the address e).

virtual size_t RWSlistCollectables::entries (  )  const [inline, virtual]

Returns the total number of items in the collection.

Implements RWSequenceable.

virtual RWCollectable* RWSlistCollectables::find ( const RWCollectable target  )  const [inline, virtual]

Returns the first item that matches target, or rwnil if no item is found.

Implements RWSequenceable.

RWCollectable* RWSlistCollectables::findReference ( const RWCollectable e  )  const [inline]

Returns the first item that is identical to the item pointed to by e (that is, that has the address e), or rwnil if none is found.

virtual RWCollectable* RWSlistCollectables::first (  )  const [inline, virtual]

Returns the first item in the collection.

Implements RWSequenceable.

RWCollectable* RWSlistCollectables::get ( void   )  [inline]

Returns and removes the item at the beginning of the list.

virtual size_t RWSlistCollectables::index ( const RWCollectable c  )  const [inline, virtual]

Returns the index of the first item that isEqual() to the item pointed to by c. If there is no such item, returns RW_NPOS.

Implements RWSequenceable.

virtual RWCollectable* RWSlistCollectables::insert ( RWCollectable a  )  [inline, virtual]

Adds the item a to the end of the collection and returns it. Returns rwnil if the insertion was unsuccessful.

Implements RWSequenceable.

Reimplemented in RWSlistCollectablesStack.

virtual RWCollectable* RWSlistCollectables::insertAt ( size_t  indx,
RWCollectable e 
) [inline, virtual]

Adds a new item to the collection at position indx. The item previously at position i is moved to i+1, etc. The index indx must be between 0 and the number of items in the collection, or an exception of type RWBoundsErr will be thrown.

Implements RWSequenceable.

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

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

Reimplemented from RWCollection.

Reimplemented in RWSlistCollectablesQueue, and RWSlistCollectablesStack.

virtual bool RWSlistCollectables::isEmpty (  )  const [inline, virtual]

Returns true if the collection is empty, otherwise returns false.

Implements RWSequenceable.

virtual bool RWSlistCollectables::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 RWCollectable.

Reimplemented in RWSlistCollectablesQueue, and RWSlistCollectablesStack.

virtual RWCollectable* RWSlistCollectables::last (  )  const [inline, virtual]

Returns the last item in the collection.

Implements RWSequenceable.

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

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

Implements RWCollection.

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

Returns a dynamically allocated iterator for the collection.

Implements RWCollection.

virtual RWCollectable* RWSlistCollectables::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 RWCollectable.

Reimplemented in RWSlistCollectablesQueue, and RWSlistCollectablesStack.

virtual size_t RWSlistCollectables::occurrencesOf ( const RWCollectable target  )  const [inline, virtual]

Returns the number of items that compare isEqual() to the item pointed to by target.

Implements RWSequenceable.

size_t RWSlistCollectables::occurrencesOfReference ( const RWCollectable e  )  const [inline]

Returns the number of items that are identical to the item pointed to by e (that is, that have the address e).

bool RWSlistCollectables::operator== ( const RWSlistCollectables s  )  const

Returns true if self and s have the same number of members and if, for every item in self, the corresponding item at the same index in s isEqual() to it.

virtual RWCollectable* RWSlistCollectables::prepend ( RWCollectable c  )  [inline, virtual]

Adds c to the beginning of the collection and returns it. Returns rwnil if the insertion was unsuccessful.

Implements RWSequenceable.

Reimplemented in RWSlistCollectablesQueue.

virtual RWCollectable* RWSlistCollectables::remove ( const RWCollectable target  )  [inline, virtual]

Removes and returns the first item that isEqual() to the item pointed to by target. Returns rwnil if there is no such item.

Implements RWSequenceable.

Reimplemented in RWSlistCollectablesQueue, and RWSlistCollectablesStack.

RWCollectable* RWSlistCollectables::removeReference ( const RWCollectable e  )  [inline]

Removes and returns the first item that is identical to the item pointed to by e (that is, that has the address e). Returns rwnil if there is no such item.

Reimplemented in RWSlistCollectablesQueue, and RWSlistCollectablesStack.

 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.