Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1631|回复: 0
打印 上一主题 下一主题

结构体做为map的key

[复制链接]

257

主题

354

帖子

1677

积分

金牌会员

Rank: 6Rank: 6

积分
1677
跳转到指定楼层
楼主
发表于 2016-5-2 12:09:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. typedef struct tagRoadKey
  2. {
  3.      int nType;
  4.      int nScale;

  5.      bool operator <(const tagRoadKey& other) const
  6.      {
  7.          if (nType < other.nType)        //类型按升序排序
  8.          {
  9.              return true;
  10.          }
  11.          else if (nType == other.nType)  //如果类型相同,按比例尺升序排序
  12.          {
  13.              return nScale < other.nScale;
  14.          }
  15.          
  16.          return false;
  17.      }
  18. }ROADKEY;



  19. typedef struct _stPmssKey
  20. {
  21.         __int64 NeSysId;
  22.         int nPsmmKeep;
  23.         int nPsmmPilotSet;
  24.         int nCarr;
  25.         int nPsmmCell;
  26.         int nPsmmSector;
  27.         bool operator < (const _stPmssKey& other) const
  28.         {
  29.                 if (NeSysId != other.NeSysId)        
  30.                 {
  31.                         return NeSysId < other.NeSysId;
  32.                 }
  33.                 else if (nPsmmKeep != other.nPsmmKeep)  
  34.                 {
  35.                         return nPsmmKeep < other.nPsmmKeep;
  36.                 }
  37.                 else if (nPsmmPilotSet != other.nPsmmPilotSet)  
  38.                 {
  39.                         return nPsmmPilotSet < other.nPsmmPilotSet;
  40.                 }
  41.                 else if (nCarr != other.nCarr)  
  42.                 {
  43.                         return nCarr < other.nCarr;
  44.                 }
  45.                 else if (nPsmmCell != other.nPsmmCell)  
  46.                 {
  47.                         return nPsmmCell < other.nPsmmCell;
  48.                 }
  49.                 else if (nPsmmSector != other.nPsmmSector)  
  50.                 {
  51.                         return nPsmmSector < other.nPsmmSector;
  52.                 }
  53.                 return false;
  54.         }

  55. } stPmssKey,*PPmssKey;
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|firemail ( 粤ICP备15085507号-1 )

GMT+8, 2024-5-6 05:54 , Processed in 0.053768 second(s), 19 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表