SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWSequenceable Class Referenceabstract

Abstract base class for collections that can be accessed by an index. More...

#include <rw/seqcltn.h>

Inheritance diagram for RWSequenceable:
RWCollection RWCollectable RWDlistCollectables RWOrdered RWSlistCollectables RWDBForeignKeyList RWSortedVector RWSlistCollectablesQueue RWSlistCollectablesStack

Public Member Functions

virtual RWCollectableappend (RWCollectable *a)=0
 
virtual void apply (RWapplyCollectable, void *)=0
 
virtual RWCollectable *& at (size_t i)=0
 
virtual const RWCollectableat (size_t i) const =0
 
virtual void clear ()=0
 
virtual size_t entries () const =0
 
virtual RWCollectablefind (const RWCollectable *) const =0
 
virtual RWCollectablefirst () const =0
 
virtual size_t index (const RWCollectable *c) const =0
 
virtual RWCollectableinsert (RWCollectable *)=0
 
virtual RWCollectableinsertAt (size_t indx, RWCollectable *e)=0
 
virtual bool isEmpty () const =0
 
virtual RWCollectablelast () const =0
 
virtual size_t occurrencesOf (const RWCollectable *) const =0
 
virtual RWCollectableprepend (RWCollectable *c)=0
 
virtual RWCollectableremove (const RWCollectable *)=0
 
- 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 ()
 
virtual bool contains (const RWCollectable *target) const
 
virtual RWClassID isA () const
 
virtual RWConstIteratornewConstIterator () const =0
 
virtual RWIteratornewIterator ()=0
 
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 RWCollectablecopy () const
 
virtual unsigned hash () const
 
virtual bool isEqual (const RWCollectable *t) const
 
virtual RWCollectablenewSpecies () 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 RWSequenceable is an abstract base class for collections that can be accessed by an index. It inherits class RWCollection as a public base class and adds a few extra virtual functions. This documentation only describes these extra functions.

Synopsis
#include <rw/seqcltn.h>
typedef RWSequenceable SequenceableCollection;
// Smalltalk typedef
Persistence
Polymorphic

Member Function Documentation

virtual RWCollectable* RWSequenceable::append ( RWCollectable a)
pure virtual

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

Implemented in RWSortedVector, RWSlistCollectablesStack, RWDlistCollectables, RWSlistCollectables, and RWOrdered.

virtual void RWSequenceable::apply ( RWapplyCollectable  ap,
void *  vp 
)
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:

void yourApplyFunction(RWCollectable* ctp, void* vp);

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.

Implements RWCollection.

Implemented in RWDlistCollectables, RWSlistCollectables, and RWOrdered.

virtual RWCollectable*& RWSequenceable::at ( size_t  i)
pure virtual

Allows access to the i th element of the collection. The return value can be used as an lvalue. The index i must be between zero and the number of items in the collection less one, or the function throws an exception of type RWBoundsErr.

Implemented in RWSortedVector, RWDlistCollectables, RWSlistCollectables, and RWOrdered.

virtual const RWCollectable* RWSequenceable::at ( size_t  i) const
pure virtual

Allows access to the i th element of the collection. The return value cannot be used as an lvalue. The index i must be between zero and the number of items in the collection less one, or an exception of type RWBoundsErr will be thrown.

Implemented in RWSortedVector, RWDlistCollectables, RWSlistCollectables, and RWOrdered.

virtual void RWSequenceable::clear ( )
pure virtual

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

Implements RWCollection.

Implemented in RWDlistCollectables, RWSlistCollectables, and RWOrdered.

virtual size_t RWSequenceable::entries ( ) const
pure virtual

Returns the total number of items in the collection.

Implements RWCollection.

Implemented in RWDlistCollectables, RWSlistCollectables, and RWOrdered.

virtual RWCollectable* RWSequenceable::find ( const RWCollectable target) const
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").

Implements RWCollection.

Implemented in RWDlistCollectables, RWSlistCollectables, and RWOrdered.

virtual RWCollectable* RWSequenceable::first ( ) const
pure virtual

Returns the first item in the collection.

Implemented in RWDlistCollectables, RWSlistCollectables, and RWOrdered.

virtual size_t RWSequenceable::index ( const RWCollectable c) const
pure virtual

Returns the index number of the first item that "matches" the item pointed to by c. If there is no such item, returns RW_NPOS. For most collections, an item "matches" the target if either isEqual() or compareTo() find equivalence, whichever is appropriate for the actual collection type.

Implemented in RWDlistCollectables, RWSlistCollectables, RWSortedVector, and RWOrdered.

virtual RWCollectable* RWSequenceable::insert ( RWCollectable c)
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.

Note
If self is a collection of key-value pairs (e.g. RWHashDictionary), this function throws std::bad_cast if c does not inherit from RWCollectableAssociation. If the collection does not contain an association with a key that "matches" the key of c, then a copy of the association is inserted and that association's key is returned. Otherwise, the insert fails by returning either rwnil or a pointer to the existing association's key.

Implements RWCollection.

Implemented in RWDlistCollectables, RWSlistCollectables, RWSortedVector, RWOrdered, and RWSlistCollectablesStack.

virtual RWCollectable* RWSequenceable::insertAt ( size_t  indx,
RWCollectable e 
)
pure 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.

Implemented in RWSortedVector, RWDlistCollectables, RWSlistCollectables, and RWOrdered.

virtual bool RWSequenceable::isEmpty ( ) const
pure virtual

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

Implements RWCollection.

Implemented in RWDlistCollectables, RWSlistCollectables, and RWOrdered.

virtual RWCollectable* RWSequenceable::last ( ) const
pure virtual

Returns the last item in the collection.

Implemented in RWDlistCollectables, RWSlistCollectables, and RWOrdered.

virtual size_t RWSequenceable::occurrencesOf ( const RWCollectable t) const
pure virtual

Returns the number of items in the collection which are "matches" for t. See function find() for a definition of matches.

Implements RWCollection.

Implemented in RWDlistCollectables, RWSlistCollectables, RWSortedVector, and RWOrdered.

virtual RWCollectable* RWSequenceable::prepend ( RWCollectable c)
pure virtual

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

Implemented in RWDlistCollectables, RWSlistCollectables, RWSortedVector, RWOrdered, and RWSlistCollectablesQueue.

virtual RWCollectable* RWSequenceable::remove ( const RWCollectable target)
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.

Implements RWCollection.

Implemented in RWDlistCollectables, RWSlistCollectables, RWOrdered, RWSlistCollectablesStack, and RWSlistCollectablesQueue.

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