next up previous contents
Next: Initialization Up: Components Previous: Record and Files

Record Iterators

Iterators are an abstraction for a pointer into, or an index on, a collection of objects. Iterator classes are usually designed so that iterators ``know'' the bounds and other information describing a collection. Iterator classes are commonly labelled by the name of the container into which they point. An advantage of iterators over simple pointers or indices is that iterators can move from one object to another (iterate) in a collection of differently sized objects, and they recognize when they have reached the end of a collection. Simple pointers, in general, treat collections of fixed-size objects.

Record Iterators are used by Trybos to specify the location of a bank in a record. They may be thought of as pointers to TRY_Generic_Banks, or as iterators into a TRY_Abstract_Record collection of TRY_Generic_Banks. In Trybos, a record iterator can be in one of two states: it can be pointing to a bank in a record, or it can be in an ``invalid'' state. Programmers should use the methods is_valid() or is_invalid() to test whether an iterator is valid before using the iterator.

TRY_Record_Iter_Any and TRY_Record_Iter_Same are the two record iterator classes in Trybos. The two classes are identical except for the iteration behavior. In the class TRY_Record_Iter_Any, the operator ++() will cause the iterator to point to the next bank of any bank name or, if the end of the record is reached, cause the iterator to become invalid. In the class TRY_Record_Iter_Same, operator ++() will cause the iterator to point to the next bank of the same bank name, or cause the iterator to become invalid.





Robert Kennedy
Mon Jul 28 13:23:28 CDT 1997