Tags:
create new tag
,
view all tags
详细解说STL map
作者:
Winter
详细解说STL map
1 stl map 介绍: map可以干什么?
2 map 使用
2.1 比较函数
2.2 插入
2.3 查找
2.4 删除
2.5 自定义类型
3 map 和hash_map
4 map使用的常见问题和答案
1 stl map 介绍: map可以干什么?
STL的好处在于封装了许多数据结构和算法(algorithm),map就是其典型代表。map,中文意思为地图,作为动词就是映射。顾名思义,map实现的功能就是帮助你建立一一对应的关系。你可以通过map存储数据,然后很快的找到他们。例如,你有许多学生的名字,要记录学生的成绩,而且要经常增加、查找或者修改某个学生的成绩,此时使用map就可以很方便的实现。 map可以干什么?下面列举一些map的常用功能:
自动建立Key - value的对应。key 和 value可以是任意你需要的类型。
根据key值快速查找记录,查找的复杂度基本是Log(N),如果有1000个记录,最多查找10次,1,000,000个记录,最多查找20次。
快速插入Key - Value 记录。
快速删除记录
根据Key 修改value记录。
遍历所有记录。
如果你用过数据库,Key就相当于一个主键,而且是建好索引的主键.
2 map 使用
2.1 比较函数
2.2 插入
2.3 查找
2.4 删除
2.5 自定义类型
3 map 和hash_map
4 map使用的常见问题和答案
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r3
<
r2
<
r1
|
B
acklinks
|
R
aw View
|
WYSIWYG
|
M
ore topic actions
Topic revision: r3 - 2005-10-10 -
WinterWen
Main
STL 中文站
Boost 中文站
搜索引擎技术
脚本编程
管理登陆
STL China
STL
STL 英文资料
最近更新
热点文章
主题列表
关于本站
TWiki 参考
中文TWiki安装
TWiki 使用入门
TWiki语法
Twiki数据迁移
友情链接
C++编程网
My Study
比较全的c/c++资源网站
c/c++手册网站
Home
Site map
Main web
Sandbox web
ScriptProgram web
STL web
STLEnglish web
TWiki web
Main Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
E
dit
A
ttach
Copyright © 2008-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback
京ICP备05049167号