159# include <tclap/CmdLine.h>
165using namespace Aleph;
186 cout <<
"Inserting " << n <<
" elements into hash table..." << endl;
187 for (
size_t i = 0; i < n; ++i)
190 auto ptr =
tbl.insert(i,
foo);
191 assert(ptr !=
nullptr);
196 cout <<
" Inserted " << i <<
" elements" << endl;
198 cout <<
"Insertion complete. Table size: " <<
tbl.size() << endl;
203 cout <<
"Verifying all elements..." << endl;
205 for (
auto it =
backup.get_it(); it.has_curr(); it.next())
207 const Foo &
foo = it.get_curr();
208 auto ptr =
tbl.search(
foo.i);
209 assert(ptr !=
nullptr);
210 assert(ptr->first ==
foo.i);
211 assert(ptr->second ==
foo);
215 cout <<
"Verification complete. " <<
count <<
" elements verified." << endl;
222 TCLAP::CmdLine
cmd(
"Hash table resize example",
' ',
"1.0");
224 TCLAP::ValueArg<size_t> nArg(
"n",
"count",
225 "Number of keys to insert",
226 false, 1000,
"size_t");
229 cmd.parse(argc, argv);
231 size_t n = nArg.getValue();
233 cout <<
"Hash Resize Example" << endl;
234 cout <<
"===================" << endl;
235 cout <<
"Testing with " << n <<
" elements" << endl << endl;
241 cout << endl <<
"Test passed successfully!" << endl;
243 catch (TCLAP::ArgException &e)
245 cerr <<
"Error: " << e.error() <<
" for arg " << e.argId() << endl;
MapOLhash< int, Foo > tbl
Main namespace for Aleph-w library functions.
void fill(Itor beg, const Itor &end, const T &value)
Fill a range with a value.
and
Check uniqueness with explicit hash + equality functors.
std::string to_string(const time_t t, const std::string &format)
Format a time_t value into a string using format.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Open addressing hash map using linear probing.
bool operator==(const Foo &foo) const
Dynamic map with open hashing.