C + + STL common traversal algorithm

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.