key.h

来自「这是本人精心搜集的关于常用图论算法的一套源码」· C头文件 代码 · 共 36 行

H
36
字号
// Definition of a Key class:
class Key
{ public:
   static int comparisons;
    Key(int x=0)
      { key = x;  }
    int the_key( ) const{ return key; } 
    Key& operator=(const int x)
     { key = x;  return *this; }
    Key& operator=(const Key& copy)
     { key = copy.key;  return *this; }       
  protected:
    int key;
};

int Key::comparisons = 0;
bool operator==(const Key &x, const Key &y)
{  Key::comparisons++;
   return x.the_key( ) == y.the_key( );
}
bool operator>(const Key &x, const Key &y)
{  Key::comparisons++;
   return x.the_key( ) > y.the_key( );
}
bool operator>=(const Key &x, const Key &y)
{  Key::comparisons++;
   return x.the_key( ) >= y.the_key( );
}
bool operator<(const Key &x, const Key &y)
{  Key::comparisons++;
   return x.the_key( ) < y.the_key( );
}
bool operator<=(const Key &x, const Key &y)
{  Key::comparisons++;
   return x.the_key( ) <= y.the_key( );
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?