ihash.cpp

来自「数据结构c++语言描述 Borland C++实现」· C++ 代码 · 共 43 行

CPP
43
字号

#include<iostream.h>
#include "ihash.h"
class element {
   public:
      int data;
      int key;
      operator int() const {return key;}
};


IdealHashTable<element> h(100,5);
element e;

void main(void)
{
   e.key = 80;
   h.Insert(e);
   e.key = 40;
   h.Insert(e);
   e.key = 65;
   h.Insert(e);
   e.key = 58;
   h.Insert(e);
   e.key = 24;
   h.Insert(e);
   h.Output();
   e.key = 2;
   try {h.Insert(e);}
   catch (NoMem) {
      cout << "This insert should fail " 
           << endl;
      }
   h.Delete(80,e);
   cout << e << " deleted" << endl;
   h.Output();
   h.Search(24,e);
   cout << "Found " << e << endl;
   e.key = 13;
   h.Insert(e);
   h.Output();
}

⌨️ 快捷键说明

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