SourcePro® 2022.1 |
SourcePro® API Reference Guide |
Represents a group of ordered items, accessible by an index number, but not accessible by an external key. More...
#include <rw/ordcltn.h>
Public Member Functions | |
RWOrdered () | |
RWOrdered (size_t size) | |
RWOrdered (const RWOrdered &o) | |
RWOrdered (RWOrdered &&o) | |
virtual RWCollectable * | append (RWCollectable *a) |
virtual void | apply (RWapplyCollectable ap, void *x) |
virtual RWCollectable *& | at (size_t i) |
virtual const RWCollectable * | at (size_t i) const |
virtual void | clear () |
virtual RWCollectable * | copy () const |
virtual size_t | entries () const |
virtual RWCollectable * | find (const RWCollectable *target) const |
virtual RWCollectable * | first () const |
virtual size_t | index (const RWCollectable *c) const |
virtual RWCollectable * | insert (RWCollectable *c) |
virtual RWCollectable * | insertAt (size_t indx, RWCollectable *e) |
virtual RWClassID | isA () const |
virtual bool | isEmpty () const |
virtual bool | isEqual (const RWCollectable *a) const |
virtual RWCollectable * | last () const |
virtual size_t | newCapacity (size_t) const |
virtual RWConstIterator * | newConstIterator () const |
virtual RWIterator * | newIterator () |
virtual RWCollectable * | newSpecies () const |
virtual size_t | occurrencesOf (const RWCollectable *target) const |
RWCollectable *& | operator() (size_t i) |
RWOrdered & | operator= (const RWOrdered &o) |
RWOrdered & | operator= (RWOrdered &&o) |
bool | operator== (const RWOrdered &od) const |
RWCollectable *& | operator[] (size_t i) |
RWCollectable * | pop () |
virtual RWCollectable * | prepend (RWCollectable *c) |
void | push (RWCollectable *c) |
virtual RWCollectable * | remove (const RWCollectable *target) |
RWCollectable * | removeAt (size_t index) |
void | swap (RWOrdered &o) |
RWCollectable * | top () 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 (RWvistream &) |
virtual void | restoreGuts (RWFile &) |
virtual void | saveGuts (RWvostream &) const |
virtual void | saveGuts (RWFile &) const |
RWCollection * | select (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 |
Related Functions inherited from RWCollection | |
typedef void(* | RWapplyCollectable) (RWCollectable *, void *) |
typedef bool(* | RWtestCollectable) (const RWCollectable *, const void *) |
typedef bool(* | RWtestCollectablePair) (const RWCollectable *, const RWCollectable *, const void *) |
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.
RWOrdered::RWOrdered | ( | ) |
Constructs an RWOrdered with an initial capacity of RWCollection::DEFAULT_CAPACITY.
RWOrdered::RWOrdered | ( | size_t | size | ) |
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.
|
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 |
Invokes the function pointer ap on each item in the collection, in order, from first to last.
Implements RWSequenceable.
|
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.
|
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 |
Removes all objects from the collection. Does not delete the objects themselves.
Implements RWSequenceable.
|
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.
|
inlinevirtual |
Returns the total number of items in the collection.
Implements RWSequenceable.
|
virtual |
Returns the first item that isEqual() to the item pointed to by target, or rwnil if no item was found.
Implements RWSequenceable.
|
virtual |
Returns the first item in the collection.
Implements RWSequenceable.
|
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 |
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 |
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 |
|
inlinevirtual |
Returns true
if the collection is empty, otherwise returns false
.
Implements RWSequenceable.
|
virtual |
Behaves as if compareTo(t) was invoked, returning true
if the result equals 0, false
otherwise.
Reimplemented from RWCollectable.
Reimplemented in RWSortedVector.
|
virtual |
Returns the last item in the collection.
Implements RWSequenceable.
|
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.
|
virtual |
Returns a const pointer to a dynamically allocated iterator for the collection.
Implements RWCollection.
|
virtual |
Returns a dynamically allocated iterator for the collection.
Implements RWCollection.
|
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.
|
virtual |
Returns the number of items that compare isEqual() to the item pointed to by target.
Implements RWSequenceable.
Reimplemented in RWSortedVector.
|
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.
Assignment operator. Makes a shallow copy of o.
Move assignment. Self takes ownership of the data owned by 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.
|
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.
|
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.
|
virtual |
Adds c to the beginning of the collection and returns it. Returns rwnil if the insertion was unsuccessful.
Implements RWSequenceable.
Reimplemented in RWSortedVector.
|
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.
|
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.
|
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 © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |