SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWSlistCollectables Class Reference

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

Public Member Functions

 RWSlistCollectables ()
 
 RWSlistCollectables (RWCollectable *a)
 
 RWSlistCollectables (const RWSlistCollectables &lst)
 
 RWSlistCollectables (RWSlistCollectables &&lst)
 
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
 
bool containsReference (const RWCollectable *e) const
 
virtual RWCollectablecopy () const
 
virtual size_t entries () const
 
virtual RWCollectablefind (const RWCollectable *target) const
 
RWCollectablefindReference (const RWCollectable *e) const
 
virtual RWCollectablefirst () const
 
RWCollectableget ()
 
virtual size_t index (const RWCollectable *c) const
 
virtual RWCollectableinsert (RWCollectable *a)
 
virtual RWCollectableinsertAt (size_t indx, RWCollectable *e)
 
virtual RWClassID isA () const
 
virtual bool isEmpty () const
 
virtual bool isEqual (const RWCollectable *) const
 
virtual RWCollectablelast () const
 
virtual RWConstIteratornewConstIterator () const
 
virtual RWIteratornewIterator ()
 
virtual RWCollectablenewSpecies () const
 
virtual size_t occurrencesOf (const RWCollectable *target) const
 
size_t occurrencesOfReference (const RWCollectable *e) const
 
RWSlistCollectablesoperator= (RWSlistCollectables &&rhs)
 
RWSlistCollectablesoperator= (const RWSlistCollectables &rhs)
 
bool operator== (const RWSlistCollectables &s) const
 
virtual RWCollectableprepend (RWCollectable *a)
 
virtual RWCollectableremove (const RWCollectable *target)
 
RWCollectableremoveReference (const RWCollectable *e)
 
- 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 void clearAndDestroy ()
 
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
 
RWCollectionselect (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
 

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 RWCollectable::isEqual() 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>
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.

RWSlistCollectables::RWSlistCollectables ( const RWSlistCollectables lst)
inline

Makes a shallow copy of lst.

RWSlistCollectables::RWSlistCollectables ( RWSlistCollectables &&  lst)
inline

Move constructor. The constructed RWSlistCollectables takes ownership of the data owned by lst.

Condition:
This method is available only on platforms with rvalue reference support.

Member Function Documentation

virtual RWCollectable* RWSlistCollectables::append ( RWCollectable a)
inlinevirtual

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 
)
inlinevirtual

Invokes the function pointer ap on each item in the collection, in order from first to last.

Implements RWSequenceable.

virtual RWCollectable*& RWSlistCollectables::at ( size_t  i)
inlinevirtual

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 const RWCollectable* RWSlistCollectables::at ( size_t  i) const
inlinevirtual

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 void RWSlistCollectables::clear ( )
inlinevirtual

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

Implements RWSequenceable.

virtual bool RWSlistCollectables::contains ( const RWCollectable target) const
inlinevirtual

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 RWCollectable* RWSlistCollectables::copy ( ) const
virtual

Returns a new, copy-constructed object of the same type as self. The caller is responsible for deleting the object.

Reimplemented from RWCollectable.

Reimplemented in RWSlistCollectablesStack, and RWSlistCollectablesQueue.

virtual size_t RWSlistCollectables::entries ( ) const
inlinevirtual

Returns the total number of items in the collection.

Implements RWSequenceable.

virtual RWCollectable* RWSlistCollectables::find ( const RWCollectable target) const
inlinevirtual

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
inlinevirtual

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
inlinevirtual

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)
inlinevirtual

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 
)
inlinevirtual

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 RWSlistCollectablesStack, and RWSlistCollectablesQueue.

virtual bool RWSlistCollectables::isEmpty ( ) const
inlinevirtual

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

Implements RWSequenceable.

virtual bool RWSlistCollectables::isEqual ( const RWCollectable t) const
virtual

Behaves as if compareTo(t) was invoked, returning true if the result equals 0, false otherwise.

Reimplemented from RWCollectable.

Reimplemented in RWSlistCollectablesStack, and RWSlistCollectablesQueue.

virtual RWCollectable* RWSlistCollectables::last ( ) const
inlinevirtual

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

Returns a new, default-constructed object of the same type as self. The caller is responsible for deleting the object.

Reimplemented from RWCollectable.

Reimplemented in RWSlistCollectablesStack, and RWSlistCollectablesQueue.

virtual size_t RWSlistCollectables::occurrencesOf ( const RWCollectable target) const
inlinevirtual

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).

RWSlistCollectables& RWSlistCollectables::operator= ( RWSlistCollectables &&  rhs)
inline

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

Condition:
This method is available only on platforms with rvalue reference support.
RWSlistCollectables& RWSlistCollectables::operator= ( const RWSlistCollectables rhs)
inline

Assignment operator. Makes a shallow copy of rhs.

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)
inlinevirtual

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)
inlinevirtual

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 RWSlistCollectablesStack, and RWSlistCollectablesQueue.

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.

Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.