📄 ualdictmain.cpp
字号:
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
#include "book.h"
#include "compare.h"
#include "alist.h"
#include "UALdict.h"
// Driver class for unsorted array-based dictionary
int main(int argc, char** argv) {
UALdict<int, Int, intIntCompare, IntIntCompare> dict;
Int val;
dict.insert(10);
if (dict.find(10, val))
cout << "Found value " << val << " to match key value 10\n";
else
cout << "Nothing found to match key value 10\n";
dict.insert(15);
if (dict.find(5, val))
cout << "Found value " << val << " to match key value 5\n";
else
cout << "Nothing found to match key value 5\n";
dict.insert(10);
cout << "Size is " << dict.size() << endl;
if (dict.find(10, val))
cout << "Found value " << val << " to match key value 10\n";
else
cout << "Nothing found to match key value 10\n";
if (dict.remove(10, val))
cout << "Removed value " << val << " to match key value 10\n";
else
cout << "Nothing found to match key value 10\n";
if (dict.find(10, val))
cout << "Found value " << val << " to match key value 10\n";
else
cout << "Nothing found to match key value 10\n";
if (dict.remove(10, val))
cout << "Remove value " << val << " to match key value 10\n";
else
cout << "Nothing found to remove with key value 10\n";
if (dict.remove(10, val))
cout << "Remove value " << val << " to match key value 10\n";
else
cout << "Nothing found to remove with key value 10\n";
cout << "Size is " << dict.size() << endl;
dict.clear();
if (dict.find(10, val))
cout << "Found value " << val << " to match key value 10\n";
else
cout << "Nothing found to match key value 10\n";
cout << "Size is " << dict.size() << endl;
cout << "Now, do interator\n";
dict.insert(25);
dict.insert(30);
dict.insert(21);
Int e;
while (dict.removeAny(e))
cout << "Got element " << e << endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -