container() findNext() insertAfterPoint() |
key() ListIterator() operator() |
operator++() operator+=() remove() |
removeNext() reset() |
#include <rwsf/core/List.h>
rwsf::ListIterator<T> provides an iterator interface to class std::list.
The order of iteration over an rwsf::ListIterator<T> is dependent on the order of insertion of the values into the Agent.
The current item referenced by this iterator is undefined after construction or after a call to reset(). The iterator becomes valid after being advanced with either a preincrement or operator().
For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equal to false until reset() is called.
The value type must have operator== and operator< defined.
#include <rwsf/core/List.h> #include<iostream> #include <rwsf/core/CString.h> int main(){ std::list<std::string> a; a.insert("John"); a.insert("Steve"); a.insert("Mark"); a.insert("Steve"); std::listIterator<std::string> itr(a); while(itr()) { std::cout << itr.key().data << std::endl; } return 0; }
Program Output
John Steve Mark Steve
ListIterator(List<T>& s);
Creates an iterator for the singly linked list s. The iterator begins in an undefined state and must be advanced before the first element will be accessible.
ListIterator(const ListIterator<T>&);
Copy constructor.
bool operator()();
Advances self to the next element. If the iterator has advanced past the last element in the collection, false will be returned. Otherwise, true will be returned.
bool operator++();
Advances self to the next element. If the iterator has been reset or just created, self will reference the first element. If, before iteration, self referenced the last value in the list, self will now reference an undefined value distinct from the reset value and false will be returned. Otherwise, true is returned. Note: no postincrement operator is provided.
bool operator+=(size_t n);
Behaves as if the operator++ member function had been applied n times
List<T>* container() const;
Returns a pointer to the collection being iterated over.
bool findNext(const T& a);
Advances self to the first element t encountered by iterating forward, such that the expression (t == a) is true. Returns true if an element was found, returns false otherwise.
bool findNext(bool(*testFun)(const T&, void*), void* d);
Advances self to the first element t encountered by iterating forward such that the expression((*testFun)(t,d)) is true. testFun points to a user-defined tester function which must have prototype:
bool yourTester(const T& a, void* d);
Client data may be passed through parameter d. Returns true if an element was found, returns false otherwise.
void insertAfterPoint(const T& a);
Inserts a into the Agent directly after the element referenced by self.
T& key() const;
Returns a reference to the stored value.
bool remove();
Removes the value referenced by self from the collection. Returns true if the removal is successful; otherwise false.
bool removeNext(const T& a);
Removes the first element t, encountered by iterating self forward, such that the expression (t == a) is true. Returns true if an element was found and removed; otherwise returns false.
bool removeNext(bool(*testFun)(const T&, void*), void* d);
Removes the first element t, encountered by iterating self forward, such that the expression((*testFun)(t,d)) is true. testFun points to a user-defined tester function which must have prototype:
bool yourTester(const T& a, void* d);
Client data may be passed through parameter d. Returns true if an element was found and removed; otherwise returns false.
void reset(); void reset(List<T>& s);
Resets the iterator so that after being advanced it will reference the first element of the collection. Using reset() with no argument will reset the iterator on the current Agent. Supplying an std::list to reset() will reset the iterator on the new Agent.
©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks and HydraSDO is a trademark of Quovadx, 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.