Author Topic: OuterIterator  (Read 943 times)

Offline chinmay.sahooTopic starter

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 2
  • Posts: 158
  • Karma: 0
    • We Helpline
« on: 05-18-2016, 00:11:57 »
Sometimes it is advantageous to enclose one or more iterators in another iterator, such as when you want to sequentially iterate several different iterators (which you can do with the AppendIterator, as discussed later in this chapter). For this purpose, you can use the OuterIterator interface.

The definition of the OuterIterator interface is as follows:

interface OuterIterator extends Iterator {
function getInnerIterator();

This interface differs from the IteratorAggregate interface in that it extends the Iterator interface; thus, any class implementing it must also implement all the Iterator-defined methods.

The getInnerIterator() method should return the currently iterating iterator. For example,when two or more iterators are appended together and iterated one after the other, the getInnerIterator() method must return the first iterator, then the second, and so on, as the
array pointer is increased by the next() method.

This interface forms the base interface for several more specialized iterators, including AppendIterator, CachingIterator, FilterIterator, IteratorIterator, LimitIterator, and RecursiveIteratorIterator