Iterators – HP Integrity NonStop J-Series User Manual
Page 285

Click on the banner to return to the user guide home page.
©Copyright 1996 Rogue Wave Software
Iterators
Since the drafting of the ANSI/ISO Standard C++ Library, there are now two kinds of iterators
available for use in Tools.h++: the traditional iterators which we describe in detail throughout
this manual, and the new "Standard Library" iterators. For more information about using the
iterators now mandated by the standard, we refer you to the manual which came with your
version of the Standard C++ Library. In this Tools.h++ manual, unless we specifically say
otherwise, an iterator refers to a traditional iterator.
Immediately after construction, the position of a Tools.h++ iterator is formally undefined. You
must advance it or position it before it has a well-defined position. The rule of thumb is
"advance and then return." If the end of the collection has been reached, the return value after
advancing will be special, either FALSE or nil, depending on the type of iterator.
Hence, the proper idiom is:
RWSlistCollectables ct;
RWSlistCollectablesIterator it(ct);
.
.
.
RWCollectable* c;
while (c=it()) {
// Use c
}