Before going further into STL algorithms, we are going to take a deeper look at iterators in C++, as they form the basis of STL algorithms. Note that the iterator concept is not at all a C++ exclusive concept, rather it exists in most programming languages. What differentiates the C++ implementation of the iterator concept from other programming languages is that C++ mimics the syntax of raw memory pointers.
A simplified basic iterator is an object which represent a position in a sequence and therefore basically incorporate the following functionality:
- Are we out of the sequence? (denoted as is_end() -> bool)
- Retrieve the value at the current position (denoted read() -> T)
- Step to the next position (denoted step_fwd() -> void)
Note that the named functions is_end(), read() and so on, does not exist in C++, they are only here for readability. In...