本文共 3221 字,大约阅读时间需要 10 分钟。
用法汇总
insert | 插入一个元素 |
size | 获得map中元素的个数 |
max_size | 获得map所能容纳的元素个数 |
count | 判断是否存在某个key,存在为返回1 |
find | 查找某个key |
erase | 删除指定的元素 |
clear | 清空map |
empty | 判断map是否为空 |
begin | 获取map的第一个元素,一般遍历的时候用 |
end | 获取map的最后一个元素,一般遍历的时候用 |
rbegin | 获取map的第一个元素,一般倒序遍历时候用 |
rend | 获取map的最后一个元素,一般倒序遍历时候用 |
value_comp | Retrieves a copy of the comparison object that is used to order element values in a map. |
lower_bound | Returns an iterator to the first element in a map that has a key value that is equal to or greater than that of a specified key. |
upper_bound | Returns an iterator to the first element in a map that has a key value that is greater than that of a specified key. |
swap | Exchanges the elements of two maps. |
equal_range | Returns a pair of iterators. The first iterator in the pair points to the first element in a map with a key that is greater than a specified key. The second iterator in the pair points to the first element in the map with a key that is equal to or greater than the key. |
get_allocator | Returns a copy of the allocator object that is used to construct the map. |
key_comp | Returns a copy of the comparison object that used to order keys in a |
用法示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
转载地址:http://esmws.baihongyu.com/