SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches

Represents a group of ordered items, accessible by an index number, but not accessible by an external key. More...

#include <rw/ordcltn.h>

Inheritance diagram for RWOrdered:
RWSequenceable RWCollection RWCollectable RWDBForeignKeyList RWSortedVector

Public Member Functions

 RWOrdered ()
 
 RWOrdered (const RWOrdered &o)
 
 RWOrdered (RWOrdered &&o)
 
 RWOrdered (size_t size)
 
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 RWCollectablecopy () 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 *c)
 
virtual RWCollectableinsertAt (size_t indx, RWCollectable *e)
 
virtual RWClassID isA () const
 
virtual bool isEmpty () const
 
virtual bool isEqual (const RWCollectable *a) const
 
virtual RWCollectablelast () const
 
virtual size_t newCapacity (size_t) const
 
virtual RWConstIteratornewConstIterator () const
 
virtual RWIteratornewIterator ()
 
virtual RWCollectablenewSpecies () const
 
virtual size_t occurrencesOf (const RWCollectable *target) const
 
RWCollectable *& operator() (size_t i)
 
RWOrderedoperator= (const RWOrdered &o)
 
RWOrderedoperator= (RWOrdered &&o)
 
bool operator== (const RWOrdered &od) const
 
RWCollectable *& operator[] (size_t i)
 
RWCollectablepop ()
 
virtual RWCollectableprepend (RWCollectable *c)
 
void push (RWCollectable *c)
 
virtual RWCollectableremove (const RWCollectable *target)
 
RWCollectableremoveAt (size_t index)
 
void swap (RWOrdered &o)
 
RWCollectabletop () const
 
- 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
 
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 RWOrderedConstIterator
 
class RWOrderedIterator
 

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 RWOrdered represents a group of ordered items, accessible by an index number, but not accessible by an external key. Duplicates are allowed. The ordering of elements is determined externally, generally by the order of insertion and removal. An object stored by RWOrdered must inherit from the abstract base class RWCollectable.

Class RWOrdered is implemented as a vector of pointers, allowing for more efficient traversing of the collection than the linked list classes RWSlistCollectables and RWDlistCollectables, but with slower insertion in the center of the collection.

Synopsis
#include <rw/ordcltn.h>
Represents a group of ordered items, accessible by an index number, but not accessible by an external...
Definition ordcltn.h:57
Persistence
Polymorphic

Constructor & Destructor Documentation

◆ RWOrdered() [1/4]

RWOrdered::RWOrdered ( )

Constructs an RWOrdered with an initial capacity of RWCollection::DEFAULT_CAPACITY.

◆ RWOrdered() [2/4]

RWOrdered::RWOrdered ( size_t size)

Constructs an RWOrdered with an initial capacity of size.

◆ RWOrdered() [3/4]

RWOrdered::RWOrdered ( const RWOrdered & o)

Copy constructor. Makes a shallow copy of o.

◆ RWOrdered() [4/4]

RWOrdered::RWOrdered ( RWOrdered && o)

Move constructor. The constructed RWOrdered takes ownership of the data owned by o.

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

Member Function Documentation

◆ append()

virtual RWCollectable * RWOrdered::append ( RWCollectable * a)
virtual

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

Implements RWSequenceable.

Reimplemented in RWSortedVector.

◆ apply()

virtual void RWOrdered::apply ( RWapplyCollectable ap,
void * x )
virtual

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

Implements RWSequenceable.

◆ at() [1/2]

virtual RWCollectable *& RWOrdered::at ( size_t i)
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.

Implements RWSequenceable.

Reimplemented in RWSortedVector.

◆ at() [2/2]

virtual const RWCollectable * RWOrdered::at ( size_t i) const
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.

Implements RWSequenceable.

Reimplemented in RWSortedVector.

◆ clear()

virtual void RWOrdered::clear ( )
virtual

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

Implements RWSequenceable.

◆ copy()

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

◆ entries()

virtual size_t RWOrdered::entries ( ) const
inlinevirtual

Returns the total number of items in the collection.

Implements RWSequenceable.

◆ find()

virtual RWCollectable * RWOrdered::find ( const RWCollectable * target) const
virtual

Returns the first item that isEqual() to the item pointed to by target, or rwnil if no item was found.

Implements RWSequenceable.

◆ first()

virtual RWCollectable * RWOrdered::first ( ) const
virtual

Returns the first item in the collection.

Implements RWSequenceable.

◆ index()

virtual size_t RWOrdered::index ( const RWCollectable * c) const
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.

Implements RWSequenceable.

Reimplemented in RWSortedVector.

◆ insert()

virtual RWCollectable * RWOrdered::insert ( RWCollectable * c)
virtual

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

Implements RWSequenceable.

Reimplemented in RWSortedVector.

◆ insertAt()

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

Reimplemented in RWSortedVector.

◆ isA()

virtual RWClassID RWOrdered::isA ( ) const
virtual

Returns __RWORDERED.

Reimplemented from RWCollection.

Reimplemented in RWSortedVector.

◆ isEmpty()

virtual bool RWOrdered::isEmpty ( ) const
inlinevirtual

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

Implements RWSequenceable.

◆ isEqual()

virtual bool RWOrdered::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 RWSortedVector.

◆ last()

virtual RWCollectable * RWOrdered::last ( ) const
virtual

Returns the last item in the collection.

Implements RWSequenceable.

◆ newCapacity()

virtual size_t RWOrdered::newCapacity ( size_t ) const
virtual

Called by resize() to determine the new container capacity. The default implementation resizes the container in fixed increments. By overriding this method in derived classes, users may alter the resizing policy of the RWOrdered based containers.

◆ newConstIterator()

virtual RWConstIterator * RWOrdered::newConstIterator ( ) const
virtual

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

Implements RWCollection.

◆ newIterator()

virtual RWIterator * RWOrdered::newIterator ( )
virtual

Returns a dynamically allocated iterator for the collection.

Implements RWCollection.

◆ newSpecies()

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

◆ occurrencesOf()

virtual size_t RWOrdered::occurrencesOf ( const RWCollectable * target) const
virtual

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

Implements RWSequenceable.

Reimplemented in RWSortedVector.

◆ operator()()

RWCollectable *& RWOrdered::operator() ( size_t i)
inline

Returns the i th element in the collection. Bounds checking is enabled by defining the preprocessor directive RWBOUNDS_CHECK before including the header file ordcltn.h. In this case, if i is out of range, the function throws an exception of type RWBoundsErr. The results of this function can be used as an lvalue.

◆ operator=() [1/2]

RWOrdered & RWOrdered::operator= ( const RWOrdered & o)

Assignment operator. Makes a shallow copy of o.

◆ operator=() [2/2]

RWOrdered & RWOrdered::operator= ( RWOrdered && o)

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

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

◆ operator==()

bool RWOrdered::operator== ( const RWOrdered & od) const

Returns true if for every item in self, the corresponding item in od at the same index isEqual(). The two collections must also have the same number of members.

◆ operator[]()

RWCollectable *& RWOrdered::operator[] ( size_t i)
inline

Returns the i th element in the collection. If i is out of range, the function throws an exception of type RWBoundsErr. The results of this function can be used as an lvalue.

◆ pop()

RWCollectable * RWOrdered::pop ( )
inline

This is an alternative implementation of a stack to class RWSlistCollectablesStack. The last item in the collection is removed and returned. If there are no items in the collection, rwnil is returned.

◆ prepend()

virtual RWCollectable * RWOrdered::prepend ( RWCollectable * c)
virtual

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

Implements RWSequenceable.

Reimplemented in RWSortedVector.

◆ push()

void RWOrdered::push ( RWCollectable * c)
inline

This is an alternative implementation of a stack to class RWSlistCollectablesStack. The item pointed to by c is put at the end of the collection.

◆ remove()

virtual RWCollectable * RWOrdered::remove ( const RWCollectable * target)
virtual

Removes the first item that isEqual() to the item pointed to by target and returns it. Returns rwnil if no item was found.

Implements RWSequenceable.

◆ removeAt()

RWCollectable * RWOrdered::removeAt ( size_t index)

Removes the item at the position index in the collection and returns it.

◆ swap()

void RWOrdered::swap ( RWOrdered & o)

Swaps the data owned by self with the data owned by o.

◆ top()

RWCollectable * RWOrdered::top ( ) const
inline

This is an alternative implementation of a stack to class RWSlistCollectablesStack. The last item in the collection is returned. If there are no items in the collection, rwnil is returned.

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