Preliminary understanding of STL adapters

Source: Internet
Author: User

There are three types of adapters in C + +: Container adapter, iterator adapter, and function adapter. Here are the following:

1. Container adapter: Because these containers are implemented based on other standard containers, which are called container adapters, specifically stack,queue,priority_queue, stack and queue are implemented based on deque, by default, Priority_queue is implemented on a vector, you can specify the type of container according to the second argument, but be sure to conform to the standard, and queue requires push_front operation and therefore cannot be built on the vector, priority_ Front requires random access and is therefore built on top of the vector. The priority queue is a large top heap by default, which is high priority, which can be customized after the precedence comparison rule

2. Iterator adapter: includes three kinds of reverse (reverse) adapters, insert (placement-type) iterators, stream (stream) adapters. Reverse adapter: such as Rbegin (), rend (), etc.

Insert iterator: is an iterator adapter with a container parameter and generates an iterator that provides three types of back_inserter (container), Front_inserter (Container), Inserter (container, position).

Stream adapter: such as Ostream_iterator,istream_iterator.

3. Function Adapter , used to extend unary and two function objects, such as functor function pair image and so on. Used for operations before the container and the algorithm.

Preliminary understanding of STL adapters

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.