In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to use the map standard template library in C++", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use the map standard template library in C++.
One: introduction
Map is the relational container of STL, which is stored in the form of key-value. The red-black tree (balanced binary search tree) is used as the underlying data structure, and the data can be sorted automatically.
The namespace is std and belongs to the header file Note: no
Second, common operations
Capacity:
Data of actual data in a.map: map.size ()
The number of most big data in b.map: map.max_size ()
c. Determine whether the container is empty: map.empty ()
Modify:
a. Insert data: map.insert ()
b. Clear the map element: map.clear ()
c. Delete the specified element: map.erase (it)
Iterator:
A.map start pointer: map.begin ()
B.map tail pointer: map.end () Note: the next position of the last element, similar to NULL, is not the last element of the container
Three: storage
Map map1; / / method 1: map1.insert (pair (2, "beijing")); / / method 2: map1 [4] = "changping"; / / method 3: map1.insert (map::value_type (1, "huilongguan")); / / method 4: map1.insert (make_pair (3, "xierqi"))
Four: traversing
For (map::iterator it=map1.begin (); itinerant mapping 1.end (); it++) {cout first
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.