The implementation of an algorithm needs a generic I/O interface. You need to decide how and where functions get data and write results, and how and what intermediate results are retained. Iterators are an existing abstraction that helps solve this problem.
An iterator is a small data type that offers a sequential view over a dataset. Put simply, it’s a class that implements a subset of the operations that pointers can perform.
The importance of iterators is that they decouple functions from the actual data storage. An algorithm reads its input via a couple of iterators [begin...end) of unspecified type and often writes its ...