36769a54fa5d35e53399a11bce4430023dbb14d0
[iot2.git] / iotjava / iotruntime / cpp / iotslave / SetRelationTest.cpp
1 #include <iostream>
2 #include "IoTSet.hpp"
3 #include "IoTRelation.hpp"
4
5 using namespace std;
6
7 int main ()
8 {
9         unordered_set<string> myset = { "red","green","blue" };
10
11         IoTSet<string> iotset(&myset);
12
13         unordered_set<string>::const_iterator got = iotset.find ("red");
14
15         if ( got == iotset.end() )
16                 cout << "not found in myset" << endl;
17         else
18                 cout << *got << " is in myset" << endl;
19
20         cout << "size: " << iotset.size() << endl;
21
22         unordered_multimap<string,string> mymap = {
23                 {"mom","church"},
24                 {"mom","college"},
25                 {"dad","office"},
26                 {"bro","school"} };
27
28         unordered_set<string>* retset = iotset.values();
29         cout << "Returned set: " << retset->size() << endl;
30         retset->erase("red");
31         cout << "Returned set: " << retset->size() << endl;
32         cout << "Original set: " << myset.size() << endl;
33
34         //cout << "one of the values for 'mom' is: ";
35         //cout << mymap.find("mom")->second;
36         //cout << endl;
37         IoTRelation<string,string> iotrel(&mymap);
38
39         std::pair<unordered_multimap<string,string>::const_iterator, 
40                 unordered_multimap<string,string>::const_iterator> ret;
41         ret = iotrel.equal_range("mom");
42         for (std::unordered_multimap<string,string>::const_iterator it=ret.first; it!=ret.second; ++it)
43                 cout << ' ' << it->second << endl;
44
45         cout << "size: " << iotrel.size() << endl;
46
47         return 0;
48 }