C ++ Map

Source: Internet
Author: User

Map is a standard container of C ++. It provides a good one-to-one relationship. Creating a map in some programs can get twice the result with half the effort.

Member Functions
(Constructor)
Construct map (Public member function) // structure, such as Map <int, int> mm;
(Destructor)
Map destructor (Public member function)
Operator =
Copy container content (Public member function) // value assignment between containers


Iterators:

Begin
Return iterator to beginning (Public member function)
End
Return iterator to end (Public member function)
Rbegin
Return reverse iterator to reverse beginning (Public member function)
Rend
Return reverse iterator to reverse end (Public member function)


Capacity:

Empty
Test whether container is empty (Public member function)
Size
Return container size (Public member function)
Max_size
Return maximum size (Public member function)


Element access:

OPERATOR []
Access element (Public member function) // overload [].


Modifiers:

Insert
Insert elements (Public member function) // insert
Erase
Erase elements (Public member function) // Delete
Swap
Swap content (Public member function) // exchange between containers
Clear
Clear content (Public member function) // clear the container


OPERATIONS:

Find
Get iterator to element (Public member function) // search. It = mm. Find ('B ');
Count
Count elements with a specific key (Public member function) // counts whether an element is in the container.
Lower_bound
Return iterator to lower bound (Public member function) // locate> = Location of the container where the key is located
Upper_bound
Return iterator to upper bound (Public member function) // locate the location of the container where> key is located
Performance_range
Get range of equal elements (Public member function)

Mutimap is a key that can store duplicates. Mutimap needs to be inserted like this. multimap <char, int> mm; mm. insert (pair <char, int> ('A', 12 ));

Others are almost the same as map !.

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.