RWSlistCollectablesIterator(3C++) RWSlistCollectablesIterator(3C++)
NameRWSlistCollectablesIterator - Rogue Wave library class
Synopsis
// Smalltalk typedef.
typedef RWSlistCollectablesIterator LinkedListIterator;
#include <rw/slistcol.h>
RWSlistCollectables sc;
RWSlistCollectablesIteratorsci(sc) ;
Description
Iterator for class RWSlistCollectables. Traverses the linked-list from
the first to last item. The "current item" is undefined immediately
after construction -- you must define it by using operator() or some
other (valid) operation. Once the iterator has advanced beyond the end
of the collection it is no longer valid -- continuing to use it will
bring undefined results.
Persistence
None
Public ConstructorRWSlistCollectablesIterator (RWSlistCollectables&);
Constructs an iterator from a singly-linked list. Immediately after
construction, the position of the iterator will be undefined.
Public Member Operators
virtual RWCollectable*
operator()();
Redefined from class RWIterator. Advances the iterator to the next
element and returns it. Returns nil when the end of the collection is
reached.
void
operator++();
Advances the iterator one item.
void
operator+=(size_t n);
Page 1
RWSlistCollectablesIterator(3C++) RWSlistCollectablesIterator(3C++)
Advances the iterator n items.
Public Member Functions
RWBoolean
atFirst() const;
Returns TRUE if the iterator is at the beginning of the list, otherwise
FALSE;
RWBoolean
atLast() const;
Returns TRUE if the iterator is at the end of the list, otherwise FALSE;
virtual RWCollectable*
findNext(const RWCollectable* target);
Redefined from class RWIterator. Moves iterator to the next item which
isEqual to the item pointed to by target and returns it. If no item is
found, returns nil and the position of the iterator will be undefined.
RWCollectable*
findNextReference(const RWCollectable* e);
Moves iterator to the next item which is identical to the item pointed to
by e (that is, that has address e) and returns it. If no item is found,
returns nil and the position of the iterator will be undefined.
RWCollectable*
insertAfterPoint(RWCollectable* a);
Insert item a after the current cursor position and return the item. The
cursor's position will be unchanged.
virtual RWCollectable*
key() const;
Redefined from class RWIterator. Returns the item at the current
iterator position.
RWCollectable*
remove();
Removes and returns the item at the current cursor position. Afterwards,
the iterator will be positioned at the previous item in the list. This
Page 2
RWSlistCollectablesIterator(3C++) RWSlistCollectablesIterator(3C++)
function is not very efficient in a singly-linked list.
RWCollectable*
removeNext(const RWCollectable* target);
Moves iterator to the next item in the list which isEqual to the item
pointed to by target, removes it from the list and returns it.
Afterwards, the iterator will be positioned at the previous item in the
list. If no item is found, returns nil and the position of the iterator
will be undefined.
RWCollectable*
removeNextReference(const RWCollectable* e);
Moves iterator to the next item in the list which is identical to the
item pointed to by e (that is, that has address e), removes it from the
list and returns it. Afterwards, the iterator will be positioned at the
previous item in the list. If no item is found, returns nil and the
position of the iterator will be undefined.
virtual void
reset();
Redefined from class RWIterator. Resets the iterator. Afterwards, the
position of the iterator will be undefined.
void
toFirst();
Moves the iterator to the beginning of the list.
void
toLast();
Moves the iterator to the end of the list.
Page 3