自定义std::set比较函数的例子

struct GenStatus
{
 DWORD  dwId;   
 DWORD  dwLastHitTick;  

 GenStatus() : dwId(0), dwLastHitTick(0){}
 static unsigned int inline GetRefeshInterval() {return T_REFRESH_TIME;} 
 bool CheckRefreshTime(){return GetTickCount() - dwLastHitTick > GetRefeshInterval();}
};

typedef struct GenStatus *PGenStatus;
struct Comp_GenStatus
{
 bool operator()(const PGenStatus p1, const PGenStatus p2) const
 {
    return p1->dwId - p2->dwId < 0;
 }
};

typedef std::set<PGenStatus, Comp_GenStatus> GEN__STATUS_SET;
typedef std::map<PGenStatus, Comp_GenStatus> GEN__STATUS_MAP;

posted on 2007-07-09 14:13  zdleek  阅读(6)  评论(0)    收藏  举报  来源