⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keychain.h

📁 data structures, algorithms and Application书的源代码
💻 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 + -