rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWOrdered Class Reference
[RWCollectable-derived]

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

List of all members.

Public Member Functions

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

Static Public Member Functions

static RWClassID classIsA ()

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>
 RWOrdered a;

Persistence

Polymorphic


Constructor & Destructor Documentation

RWOrdered::RWOrdered ( size_t  size = RWCollection::DEFAULT_CAPACITY  ) 

Constructs an RWOrdered with an initial capacity of size.

RWOrdered::RWOrdered ( const RWOrdered o  ) 

Copy constructor. Makes a shallow copy of o.

RWOrdered::RWOrdered ( RWOrdered &&  o  ) 

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

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

Member Function Documentation

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.

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

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

Implements RWSequenceable.

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.

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.

static RWClassID RWOrdered::classIsA (  )  [static]

Returns the RWClassID of this class.

Reimplemented from RWCollectable.

Reimplemented in RWSortedVector.

virtual void RWOrdered::clear (  )  [virtual]

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

Implements RWSequenceable.

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

Returns the total number of items in the collection.

Implements RWSequenceable.

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.

virtual RWCollectable* RWOrdered::first (  )  const [virtual]

Returns the first item in the collection.

Implements RWSequenceable.

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.

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.

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.

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

Returns __RWORDERED.

Reimplemented from RWCollection.

Reimplemented in RWSortedVector.

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

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

Implements RWSequenceable.

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

virtual RWCollectable* RWOrdered::last (  )  const [virtual]

Returns the last item in the collection.

Implements RWSequenceable.

virtual size_t RWOrdered::newCapacity ( size_t   )  const [virtual]

Called by RWOrdered::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.

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

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

Implements RWCollection.

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

Returns a dynamically allocated iterator for the collection.

Implements RWCollection.

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

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.

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.

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

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

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

Assignment operator. Makes a shallow copy of o.

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.

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.

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.

Reimplemented in RWSortedVector.

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.

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.

Reimplemented in RWSortedVector.

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.

RWCollectable* RWOrdered::removeAt ( size_t  index  ) 

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

void RWOrdered::swap ( RWOrdered o  ) 

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

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.

Reimplemented in RWSortedVector.

 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.