key.cpp
来自「数据结构与程序设计教材源码 数据结构与程序设计教材源码」· C++ 代码 · 共 60 行
CPP
60 行
int Key::comparisons = 0;
void Key::initialize()
{
comparisons = 0;
}
int Key::counter()
{
return comparisons;
}
Key::Key (int x)
{
key = x;
}
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();
}
bool operator <(const Key &x, const Key &y)
{
Key::comparisons++;
return x.the_key() < y.the_key();
}
int Key::the_key() const
{
return key;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?