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);
196 cout <<
" Inserted " << i <<
" elements" <<
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);
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");
231 size_t n =
nArg.getValue();
233 cout <<
"Hash Resize Example" <<
endl;
234 cout <<
"===================" <<
endl;
235 cout <<
"Testing with " << n <<
" elements" <<
endl <<
endl;
243 catch (TCLAP::ArgException &e)
245 cerr <<
"Error: " << e.error() <<
" for arg " << e.argId() <<
endl;
size_t size() const noexcept
Count the number of elements of the list.
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.
std::string to_string(const time_t t, const std::string &format)
Format a time_t value into a string using format.
DynList< T > maps(const C &c, Op op)
Classic map operation.
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.