35 #include <boost/functional/hash.hpp> 36 #include <unordered_map> 48 using std::placeholders::_1;
57 enum Colour { R,G,B };
63 static string sym(
"RGB");
64 return sym.substr(c,1);
100 cout <<
"...." << c1 << c2 << c3 << endl;
111 SubID const& id1 = CUID(R, 12);
112 SubID const& id2 = CUID(G, 13);
114 cout <<
"id1=" << id1 << endl;
115 cout <<
"id2=" << id2 << endl;
126 vector<CID> simpleIDs;
127 simpleIDs.push_back(CID(R));
128 simpleIDs.push_back(CID(R));
129 simpleIDs.push_back(CID(G));
130 simpleIDs.push_back(CID(B));
132 vector<CUID> extendedIDs;
133 extendedIDs.push_back(CUID(R,22));
134 extendedIDs.push_back(CUID(R,22));
135 extendedIDs.push_back(CUID(R,23));
136 extendedIDs.push_back(CUID(R,24));
137 extendedIDs.push_back(CUID(G,24));
138 extendedIDs.push_back(CUID(B,25));
140 buildHashtable<CID> (simpleIDs);
141 buildHashtable<CUID> (extendedIDs);
148 : std::unordered_map<KEY, string, hash<KEY>>
153 (*this)[key] = string(key);
159 cout <<
"verify....." << key << endl;
160 CHECK (
string(key) == (*
this)[key]);
167 buildHashtable (vector<KEY> keys)
173 for_each (keys, bind (&HTab::add, ref(tab), _1 ));
174 for_each (keys, bind (&HTab::verify, ref(tab), _1 ));
176 cout <<
"Elements in hashtable: " << tab.size() << endl;
string toString(Colour c)
Implementation namespace for support and library code.
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
void for_each(CON const &elements, FUN function, P1 &&bind1, ARGS &&...args)
Accept binding for arbitrary function arguments.
Extensible symbolic ID type.
Perform operations "for each element" of a collection.