📄 keychain.h
字号:
#ifndef KeyedChain_
#define KeyedChain_
// file keychain.h
// chains with keys
#include "echain.h"
template<class T>
class KeyedChain : public Chain<T> {
public:
bool Delete(T& x); // delete x
ChainNode<T> * First() const {return first;}
};
template<class T>
bool KeyedChain<T>::Delete(T& x)
{// Delete element matching x.
ChainNode<T> *i = first, *p = 0;
// search for match
for (; i && i->data != x; i = i->link) p = i;
if (!i) throw BadInput(); // no match
// match found in node i
x = i->data; // return matching element
if (p) p->link = i->link; // i is not first node
else first = i->link; // i is first node
delete i;
return *this;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -