C + + STL common traversal algorithm
Design concept of STL's container algorithm iterator
1) STL container through class template technology, to achieve the separation of data type and container model
2) STL's iterator technology realizes the unified method of traversing container, and provides the basis for the unification of STL algorithm.
3) STL algorithm, through the function object realizes the custom data type arithmetic operation, therefore: The STL algorithm also provides the unification.
Core idea: Actually the function object is the callback function, the idea of the callback function: It is the writer of the task and the caller of the task to effectively decouple. function pointers do function arguments.
4) Specific example: the input of the transform algorithm, through the iterator first and last point to the meta-calculation as input, through result as output, through the function object to do the operation of the custom data type.
Common traversal algorithms
C + + STL common traversal algorithm