SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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 (const RWSlistCollectables &lst)
 
 RWSlistCollectables (RWCollectable *a)
 
 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= (const RWSlistCollectables &rhs)
 
RWSlistCollectablesoperator= (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 (RWFile &)
 
virtual void restoreGuts (RWvistream &)
 
virtual void saveGuts (RWFile &) const
 
virtual void saveGuts (RWvostream &) 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
 

Friends

class RWSlistCollectablesIterator
 

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>
Represents a group of ordered elements without keyed access, where duplicates are allowed.
Definition slistcol.h:56
Persistence
Polymorphic

Constructor & Destructor Documentation

◆ RWSlistCollectables() [1/4]

RWSlistCollectables::RWSlistCollectables ( )

Constructs an empty linked list.

◆ RWSlistCollectables() [2/4]

RWSlistCollectables::RWSlistCollectables ( RWCollectable * a)
inline

Constructs a linked list with single item a.

◆ RWSlistCollectables() [3/4]

RWSlistCollectables::RWSlistCollectables ( const RWSlistCollectables & lst)
inline

Makes a shallow copy of lst.

◆ RWSlistCollectables() [4/4]

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

◆ append()

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.

◆ apply()

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.

◆ at() [1/2]

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.

◆ at() [2/2]

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.

◆ clear()

virtual void RWSlistCollectables::clear ( )
inlinevirtual

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

Implements RWSequenceable.

◆ contains()

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.

◆ containsReference()

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

◆ copy()

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

◆ entries()

virtual size_t RWSlistCollectables::entries ( ) const
inlinevirtual

Returns the total number of items in the collection.

Implements RWSequenceable.

◆ find()

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.

◆ findReference()

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.

◆ first()

virtual RWCollectable * RWSlistCollectables::first ( ) const
inlinevirtual

Returns the first item in the collection.

Implements RWSequenceable.

◆ get()

RWCollectable * RWSlistCollectables::get ( )
inline

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

◆ index()

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.

◆ insert()

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.

◆ insertAt()

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.

◆ isA()

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.

◆ isEmpty()

virtual bool RWSlistCollectables::isEmpty ( ) const
inlinevirtual

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

Implements RWSequenceable.

◆ isEqual()

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

◆ last()

virtual RWCollectable * RWSlistCollectables::last ( ) const
inlinevirtual

Returns the last item in the collection.

Implements RWSequenceable.

◆ newConstIterator()

virtual RWConstIterator * RWSlistCollectables::newConstIterator ( ) const
virtual

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

Implements RWCollection.

◆ newIterator()

virtual RWIterator * RWSlistCollectables::newIterator ( )
virtual

Returns a dynamically allocated iterator for the collection.

Implements RWCollection.

◆ newSpecies()

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

◆ occurrencesOf()

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.

◆ occurrencesOfReference()

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

◆ operator=() [1/2]

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

Assignment operator. Makes a shallow copy of rhs.

◆ operator=() [2/2]

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.

◆ operator==()

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.

◆ prepend()

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.

◆ remove()

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

◆ removeReference()

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 © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.