RWOrderedRWSequenceableRWCollectionRWCollectable
#include <rw/ordcltn.h> RWOrdered a;
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 slower insertion in the center of the collection.
Polymorphic
RWOrdered(size_t size = RWDEFAULT_CAPACITY);
Construct an RWOrdered with an initial capacity of size.
RWBoolean 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*& operator[](size_t i);
Returns the ith element in the collection. If i is out of range, an exception of type RWBoundsErr will occur. The results of this function can be used as an lvalue.
RWCollectable*& operator()(size_t i);
Returns the ith 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, an exception of type RWBoundsErr will occur. The results of this function can be used as an lvalue.
virtual RWCollectable* append(RWCollectable*);
Redefined from class RWSequenceable. Adds the item to the end of the collection and returns it. Returns nil if the insertion was unsuccessful.
virtual void apply(RWapplyCollectable ap, void* x);
Redefined from class RWCollection. 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.
virtual RWCollectable*& at(size_t i); virtual const RWCollectable* at(size_t i) const;
Redefined from class RWSequenceable.
virtual RWspace binaryStoreSize() const;
Inherited from class RWCollection.
virtual void clear();
Redefined from class RWCollection.
virtual void clearAndDestroy();
Inherited from class RWCollection.
virtual int compareTo(const RWCollectable* a) const;
Inherited from class RWCollectable.
virtual RWBoolean contains(const RWCollectable* target) const;
Inherited from class RWCollection.
virtual size_t entries() const;
Redefined from class RWCollection.
virtual RWCollectable* find(const RWCollectable* target) const;
Redefined from class RWCollection. Returns the first item that isEqual to the item pointed to by target, or nil if no item was found..
virtual RWCollectable* first() const;
Redefined from class RWSequenceable. Returns the first item in the collection.
virtual unsigned hash() const;
Inherited from class RWCollectable.
virtual size_t index(const RWCollectable*) const;
Redefined from class RWSequenceable.
virtual RWCollectable* insert(RWCollectable* c);
Redefined from class RWCollection. Adds the item to the end of the collection and returns it. Returns nil if the insertion was unsuccessful.
void insertAt(size_t indx, RWCollectable* e);
Redefined from class RWSequenceable. 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.
virtual RWClassID isA() const;
Redefined from class RWCollectable to return __RWORDERED.
virtual RWBoolean isEmpty() const;
Redefined from class RWCollection.
virtual RWBoolean isEqual(const RWCollectable* a) const;
Inherited from class RWCollectable.
virtual RWCollectable* last() const;
Redefined from class RWSequenceable. Returns the last item in the collection.
virtual size_t occurrencesOf(const RWCollectable* target) const;
Redefined from class RWCollection. Returns the number of items that compare isEqual to the item pointed to by target.
RWCollectable* prepend(RWCollectable*);
Redefined from class RWSequenceable. Adds the item to the beginning of the collection and returns it. Returns nil if the insertion was unsuccessful.
void push(RWCollectable* c);
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.
RWCollectable* pop();
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, nil is returned.
virtual RWCollectable* remove(const RWCollectable* target);
Redefined from class RWCollection. Removes the first item that isEqual to the item pointed to by target and returns it. Returns nil if no item was found.
RWCollectable* removeAt(size_t index);
Removes the item at the position index in the collection and returns it.
virtual void removeAndDestroy(const RWCollectable* target);
Inherited from class RWCollection.
RWCollectable* top() const;
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, nil is returned.