【C++】map
1、定义
template<
class Key,
class T,
class Compare = std::less<Key>,
class Allocator = std::allocator<std::pair<const Key, T>>
> class map;
namespace pmr {
template<
class Key,
class T,
class Compare = std::less<Key>
> using map = std::map<Key, T, Compare,
std::pmr::polymorphic_allocator<std::pair<const Key, T>>>;
}
std::map 是一种有序关联容器,它包含具有唯一键的键值对。键之间以比较函数 Compare 排序。搜索、移除和插入操作拥有对数复杂度。map 通常实现为红黑树。
std::map 的迭代器以升序迭代各键,此升序由构造时所用的比较函数定义。
2、成员类型
3、构造函数
4、元素访问
4.1 at
带边界检查。
4.2 operator[]
5、查找
5.1 find
6、迭代器
6.1 end \ cend
6.2 begin \ cbegin
6.3 rbegin \ crbegin
6.4 rend \ crend
7、容量
7.1 empty
7.2 size
7.3 max_size
8、修改器
8.1 clear
8.2 insert