-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.cpp
More file actions
82 lines (57 loc) · 1.77 KB
/
test.cpp
File metadata and controls
82 lines (57 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <fstream>
#include <iostream>
#include <sstream>
#include "dictionary.h"
using namespace std;
bool pred(const std::string& a, const std::string& b) { return a > b; }
int main(int argc, char* argv[])
{
// TODO : test new functions!
/*
if (argc < 2)
{
cout << "enter name of osgt file as argument\n";
return 1;
}
string file1 = argv[1];
ifstream fs;
fs.open(file1.c_str());
*/
Dictionary<string> dictionary;
vector<string> vec;
vec.push_back("234");
vec.push_back("nananana");
vec.push_back("nanana");
vec.push_back("nanana na");
vec.push_back("nananana");
vec.push_back("nanana");
vec.push_back("nanana na");
vec.push_back("nananana");
vec.push_back("nanana");
vec.push_back("nanana na");
vec.push_back("aardvark");
vec.push_back("ZZ Top");
vec.push_back("123");
dictionary.add(vec);
Dictionary<string> dict2;
dict2.add("strawberry fields forever");
dict2.add("Abba");
dictionary = combine(dictionary, dict2);
cout << "nananana appears " << dictionary.getVal("nananana") << " times\n";
// vector<string> sorted = dictionary.getWords([](std::string a, std::string b) { return a > b; });
vector<string> sorted = dictionary.asVector(pred);
for (auto i : sorted)
{
cout << i << endl;
}
cout << endl << endl << endl;
Dictionary<string>::const_iterator it = dictionary.begin();
while (it != dictionary.end()) cout << it++->first << endl;
cout << endl << endl;
Dictionary<string> dict3;
dict3.add("nananana");
dict3.add("here I am");
dict3.add("rock you like a hurricane");
Dictionary<string> dict4 = exclusive(dictionary, dict3);
for (auto i : dict4) cout << i.first << endl;
}