10.--pair,map,set,multimap,multiset

Source: Internet
Author: User

Map and set allow only the same keys to appear once, while Multimap and multiset allow multiple occurrences.

1. Introduction--pair Type:

Pair needs to add header file utility header file

Make_pair<v1,v2> creates a new pair object with Values V1 and V2, and the two types of this pair object are the types of these two values

Pair<t1,t2> (V1,V2)

pair<t1,t2> If you do not provide an initialization when creating a pair object, the default constructor is used to initialize the

P First P Second These two data members are common data members

2. Map type

Map must contain the map header file

The only constraint for a key type is that the < operator must be supported.

Strict weak ordering must be defined on the key type (that is, strict on the key exists less than the relationship).

(1) Type of map definition

The type of the Map<k,v>::key_type key.

map<k,v The type of the value that the >::mapped_type key is associated with.

Map<k,v>::value_type a pair type, but the key is const and cannot be modified.

10.--pair,map,set,multimap,multiset

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.