Learning C + + Primer's personal understanding (11)

Source: Internet
Author: User

Associative containers

  It's like a dictionary whose elements are key-value pairs. The keyword plays an index role.

  

 Ordered:

Map: associative arrays; Pao-value pairs

Set: The keyword is both a value.

Multimap: keyword-repeatable map

Multiset: The keyword can repeat the set

  

 Disordered:

Unordered_ First Four

Using map

  Map<sring,size_t> Word_count;

Using Set

  Set<string> Exclude

Pair type

  A pair type holds two data members.

When creating a pair, we must provide two class names.

Pair type has two members

First

Second

 

Associative container iterators

  When we dereference an iterator for an associative container, we get a reference to the value of the value_type of the container type.

For map, is a pair type, first save the const keyword, second save the value.

The set iterator is a const

adding elements

  The insert member of the associated container adds an element or an element range to the container.

  

  

Learning C + + Primer's personal understanding (11)

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.