Iterator

An iterator represents a partial computation, with a promise to complete the computation one step at a time. It is somewhat like a stream in Scheme. Each step of the computation has an associated return value; Iterator is a template class parameterized by the type of the value.

An iterator includes methods to reset a computation, get the current value, advance the computation, and test whether or not the computation is complete. A for-loop can be used to step through a computation:

  for (i->reset(); !i->at_end(); i->advance()) {
    T e = i->get();
  }
The reset can be omitted if the iterator has been just allocated.

Iterators are often used to step through containers one step at a time. In addition, many queries (e.g. faces of a ccomplex) can return either a container or an iterator. It is up to the implementation as to whether actually to construct a container and use its iterator, or to provide its own iterator without explicitly constructing the container. The second case can often be an optimization.

Subclasses:

Member functions: