Tag Archives: Aggregate

IteratorAggregate

The IteratorAggregate is an interface to create an external Iterator.

While Iterator is an interface for external iterators or objects that can be iterated themselves internally.

IteratorAggregate is an easy way to implement an Iterator. The disadvantage is you cannot add next(), key(), etc methods, as they won’t get called during a normal foreach traversal.

If you need to implement custom methods, you need to implement an OuterIterator or (easier) to extend an IteratorIterator.