forked from AndrejPetelin/CppDictionary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
69 lines (49 loc) · 1.44 KB
/
test.cpp
File metadata and controls
69 lines (49 loc) · 1.44 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
#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[])
{
/*
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 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 dict2;
dict2.add("strawberry fields forever");
dict2.add("Abba");
dictionary = combine(dictionary, dict2);
cout << "nananana appears " << dictionary.find("nananana") << " times\n";
// vector<string> sorted = dictionary.getWords([](std::string a, std::string b) { return a > b; });
vector<string> sorted = dictionary.getWords(pred);
for (auto i : sorted)
{
cout << i << endl;
}
cout << endl << endl << endl;
Dictionary::const_iterator it = dictionary.begin();
while (it != dictionary.end()) cout << it++->first << endl;
}