1. 程式人生 > >記錄一下結構體排序的問題(vector,map)

記錄一下結構體排序的問題(vector,map)

部落格遷移:http://www.codeye.top


struct CoorEx

{

 COOR co;

 bool operator < (const CoorEx& cc )  const   

 {  

  if (algv3::ISZERO( cc.co.x - this->co.x ))

  {

   return cc.co.y < this->co.y;

  } 

  else if (algv3::ISZERO( cc.co.y - this->co.y))

  {

   return cc.co.x < this->co.x;

  }

  else

   return ( cc.co.x < this->co.x );

 }

 CoorEx& operator=( const CoorEx &cc)

 {

  this->co.x = cc.co.x;

  this->co.y = cc.co.y;

  this->co.z = cc.co.z;

  return *this;

 }

};