A data structure, or container, component provides a certain type of iterator that can be used to navigate through its individual data elements. Examples of STL iterator types are forward that allow sequential traversal and random access that also allow direct access. An algorithm component often takes two iterators as input which indicate a range of elements within a container (see figure). | |||
Compatible containers and algorithms can be combined in an orthogonal
manner. To be compatible particular algorithm a container with a
must provide iterators that allows that algorithm to navigate through a
container in the way that it needs. The simpler the demands made by an
algorithm upon its input parameters, the more generic it is. The greater
the functionality of the iterators that a container provides, the greater
the range of algorithms that can operate on it.
|
|