C++如何实现哈希数据结构——map Library
2011-11-30 18:50
253 查看
C++ 的常用库
http://www.cplusplus.com/reference/
map Library
http://www.cplusplus.com/reference/stl/map/
简单用法如下:
Iterators of a map container point to elements of this value_type. Thus, for an iterator called it that points to an element of a map, its key and mapped value can be accessed respectively with:
Naturally, any other direct access operator, such as -> or [] can be used, for example:
举例:
#include <map>
using namespace std;
map <String,TEdit*> map1;
map1[ "Edit1 "]=Edit1;
map1[ "Edit2 "]=Edit2;
map1[ "Edit1 "]-> Text= "aaaaaa ";
map1[ "Edit2 "]-> Text= "bbbbbb ";
http://www.cplusplus.com/reference/
map Library
http://www.cplusplus.com/reference/stl/map/
简单用法如下:
typedef pair<const Key, T> value_type; |
1 2 3 4 | map<Key,T>::iterator it; (*it).first; // the key value (of type Key) (*it).second; // the mapped value (of type T) (*it); // the "element value" (of type pair<const Key,T>) |
1 2 | it->first; // same as (*it).first (the key value) it->second; // same as (*it).second (the mapped value) |
#include <map>
using namespace std;
map <String,TEdit*> map1;
map1[ "Edit1 "]=Edit1;
map1[ "Edit2 "]=Edit2;
map1[ "Edit1 "]-> Text= "aaaaaa ";
map1[ "Edit2 "]-> Text= "bbbbbb ";
相关文章推荐
- 程序员面试金典: 9.13 C和C++ 13.2 比较并比对散列表和STL map。散列表是如何实现的?如果输入的数据量不大,可以选用哪些数据结构替代散列表?
- 如何用c++实现四叉数的数据结构(一)
- C++的多态如何在编译和运行期实现
- 数据结构与算法——AVL树类的C++实现
- 如何用C++轻松实现线程控制-2
- C++类模板 实现双向循环链表的基本算法 《数据结构》(C++版 北京科海)中摘抄
- 数据结构C++单链表的实现
- 【C++数据结构学习笔记---线性表】用数组实现线性表
- 仅返回类型不同的函数,在C++中如何实现重载?
- 用C++实现HTTP服务器 - 如何控制一个套接字的发送带宽
- C++实现BitMap数据结构
- 在C++中如何实现文件的读写
- C++如何实现单例模式
- 数据结构 图(C++实现代码)
- extern "C" c++如何实现函数的重载
- c++和java总异常是如何用c语言实现的
- C++实现数据结构中的单链表
- Java中常见数据结构:list与map -底层如何实现
- python 下的数据结构与算法---8:哈希一下【dict与set的实现】
- 数据结构-堆 C与C++的实现