C++ map struct find
来源:互联网 发布:闪电刷新 知乎 编辑:程序博客网 时间:2024/06/06 03:12
参考:http://stackoverflow.com/questions/9647110/using-struct-as-key-and-value-for-map-find-operation-giving-error 【参考2 Answers】
示例:
struct IPPOINT{string ip;string port;};inline bool operator<(IPPOINT const& left, IPPOINT const& right) {if (left.ip < right.ip) { return true; }if (left.ip > right.ip) { return false; }return left.port < right.port;}int main(){IPPOINT i;i.ip = "12";i.port = "22";IPPOINT j;j.ip = "12";j.port = "222";IPPOINT k;k.ip = "12";k.port = "22";map<IPPOINT,int> lst;lst.insert(make_pair<IPPOINT,int>(i,1)); map<IPPOINT,int>::iterator l_it = lst.find(k);if(l_it!=lst.end())cout<<lst[k];l_it = lst.find(j);if(l_it!=lst.end())cout<<lst[j];lst.insert(make_pair<IPPOINT,int>(j,2)); l_it = lst.find(j);if(l_it!=lst.end())cout<<lst[j];return 0;}
0 0
- C++ map struct find
- find struct with gtags
- hive struct\map\array
- map vector struct+sort
- hive map,struct,array
- golang struct to map
- C struct
- 搜狗面试的经典题(C++map按值排序,class struct的区别)
- map::insert and map::find
- mmap5-map the struct file
- hive array、map、struct使用
- hive array、map、struct使用
- hive array、map、struct使用
- hive array、map、struct使用
- hive array、map、struct使用
- hive array、map、struct使用
- hive array、map、struct使用
- hive array、map、struct使用
- zoj 1178 Booklet Printing
- RabbitMQ官方中文入门教程(PHP版) 第一部分:Hello World
- IIS架构与HTTP请求处理流程(2)
- 实例讲解黑客如何执行SQL注入攻击
- 外伤性癫痫 01wty3sz
- C++ map struct find
- Unity3D技术之遮挡剔除(仅限专业版)详解
- 这边有许多资源好
- RabbitMQ官方中文入门教程(PHP版) 第二部分:工作队列(Work queues)
- 求解一元多次方程的两种方法:牛顿迭代法和二分法
- ZOJ Problem Set - 2060 Fibonacci Again
- poj1609
- WPF 中的 loaded 事件和 Initialized 事件
- RabbitMQ官方中文入门教程(PHP版) 第三部分:发布/订阅(Publish/Subscribe)