【C++】map
1.【C++】const与constexpr2.【C++】vector3.【C++】创建对象写法4.【C++】域作用符的作用
5.【C++】map
6.【C++】类7.【C++】NULL与nullptr的区别8.【C++】cmath9.【C++】struct10.【C++】string11.【C++】unordered_set12.【C++】基本类型13.【C++】algorithm14.【C++】命名空间15.【C++】缺省参数16.【C++】函数重载17.【C++】引用18.【C++】auto19.【C++】基于范围for循环20.【C++】存储区21.【C++】左值与右值22.【C++】explicit23.【C++】构造函数类别24.【C++】decltype25.【C++】remove_refrence26.【C++】typeid与RTTI27.【C++】using28.【C++】引用折叠、万能引用和完美转发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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南