Top Up Prev Next Bottom Contents Index Search

3.5 Iterators

The StringList class is one of several list classes in the Ptolemy kernel. A basic operation on list classes is to sequentially access their members one at a time. This is accomplished using an iterator class, companion to the list class. For the StringList class, the iterator is called StringListIter. Its methods are summarized in table 3-9
. An example program fragment using this is given below:

StringListIter item(myList);
const char* string;
while ((string = item++) != 0) cout << string << "\n";
In this fragment, myList is assumed to be a StringList previously set up.



Top Up Prev Next Bottom Contents Index Search

Copyright © 1990-1997, University of California. All rights reserved.