C++如何实现哈希数据结构——map Library

C++ 的常用库
http://www.cplusplus.com/reference/

map Library

http://www.cplusplus.com/reference/stl/map/

 

简单用法如下:

 
typedef pair<const Key, T> value_type;



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:

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>) 


Naturally, any other direct access operator, such as -> or [] can be used, for example:

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 ";

 

转载于:https://www.cnblogs.com/xianghang123/archive/2011/11/30/2269513.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值