26 #include <boost/functional/hash.hpp> 27 #include <unordered_map> 39 using std::placeholders::_1;
48 enum Colour { R,G,B };
54 static string sym(
"RGB");
55 return sym.substr(c,1);
91 cout <<
"...." << c1 << c2 << c3 << endl;
102 SubID const& id1 = CUID(R, 12);
103 SubID const& id2 = CUID(G, 13);
105 cout <<
"id1=" << id1 << endl;
106 cout <<
"id2=" << id2 << endl;
117 vector<CID> simpleIDs;
118 simpleIDs.push_back(CID(R));
119 simpleIDs.push_back(CID(R));
120 simpleIDs.push_back(CID(G));
121 simpleIDs.push_back(CID(B));
123 vector<CUID> extendedIDs;
124 extendedIDs.push_back(CUID(R,22));
125 extendedIDs.push_back(CUID(R,22));
126 extendedIDs.push_back(CUID(R,23));
127 extendedIDs.push_back(CUID(R,24));
128 extendedIDs.push_back(CUID(G,24));
129 extendedIDs.push_back(CUID(B,25));
131 buildHashtable<CID> (simpleIDs);
132 buildHashtable<CUID> (extendedIDs);
139 : std::unordered_map<KEY, string, hash<KEY>>
144 (*this)[key] = string(key);
150 cout <<
"verify....." << key << endl;
151 CHECK (
string(key) == (*
this)[key]);
158 buildHashtable (vector<KEY> keys)
164 for_each (keys, bind (&HTab::add, ref(tab), _1 ));
165 for_each (keys, bind (&HTab::verify, ref(tab), _1 ));
167 cout <<
"Elements in hashtable: " << tab.size() << endl;
string toString(Colour c)
Implementation namespace for support and library code.
Simplistic 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.