map def: Constructs a list of a specific size or with elements of a specific value or with a specific allocator or as a copy of some other map.
1、map之间可以用 = 或者 ! = 来比较两个map之间是否相等, multimap也可以用。
map和multimap的区别
http://blog.csdn.net/cws1214/article/details/8211881
2、multimap <int, int> m1, m2, m3;
3、map之间也可以用<=, <, >=, >
The less-than relationship between two objects is based on a comparison of the first pair of unequal elements.
4、swap( m1, m3 )
Exchanges the elements of two maps or multimaps.
关键的私有值
一个是key,用key来索引data value
有用的成员函数
5、at的使用
map<char, int> Mymap;
Mymap c1;
c1.insert(value_type('a', 1));
cout << "c1.at('a') == " << c1.at('a') <<endl;
6、begin()的使用
Returns an iterator that points to the first element in the map.
7、find()的使用
template <typename C, class T> void findit(const C& c, T val) { cout << "Trying find() on value " << val << endl; auto result = c.find(val); if (result != c.end()) { cout << "Element found: "; print_elem(*result); cout << endl; } else { cout << "Element not found." << endl; } }8、max_size()
Returns the maximum length of the map. |
Returns the number of elements in the map. |
// Insert a data value of 10 with a key of 1 // into a map using the operator[] member function m1[ 1 ] = 10;