37# include <gtest/gtest.h>
46using namespace testing;
53 EXPECT_TRUE(
tbl.is_empty());
54 EXPECT_EQ(
tbl.size(), 0);
56 const size_t cap =
tbl.capacity();
57 for (
size_t i = 0; i < cap; ++i)
59 EXPECT_EQ(
tbl.size(), i);
60 EXPECT_NE(
tbl.insert(i),
nullptr);
61 EXPECT_EQ(
tbl.size(), i + 1);
62 EXPECT_FALSE(
tbl.is_empty());
65 for (
size_t i = 0; i <
tbl.size(); ++i)
67 ASSERT_NE(
tbl.search(i),
nullptr);
68 auto ptr =
tbl.search(i);
70 EXPECT_FALSE(
tbl.is_empty());
73 for (
size_t i = 0, n =
tbl.size(); i < n; ++i)
75 auto ptr =
tbl.search(i);
78 EXPECT_EQ(
tbl.size(), n - i - 1);
79 EXPECT_EQ(
tbl.search(i),
nullptr);
80 EXPECT_FALSE(
tbl.contains(i));
83 EXPECT_EQ(
tbl.size(), 0);
84 EXPECT_TRUE(
tbl.is_empty());
98 return r1.key == r2.key;
113 EXPECT_EQ(
tbl.size(), 0);
114 EXPECT_TRUE(
tbl.is_empty());
116 for (
size_t i = 0; i < 100; ++i)
118 EXPECT_EQ(
tbl.size(), i);
120 EXPECT_EQ(
tbl.size(), i + 1);
122 EXPECT_NE(ptr,
nullptr);
123 EXPECT_EQ(ptr->key, i);
127 for (
size_t i = 0, n =
tbl.size(); i < n; ++i)
129 auto ptr =
tbl.search(i);
132 EXPECT_EQ(
tbl.size(), n - i - 1);
133 EXPECT_EQ(
tbl.search(i),
nullptr);
142 ASSERT_NE(ptr,
nullptr);
144 auto *bucket =
decltype(
tbl)::key_to_bucket(ptr);
145 ASSERT_NE(bucket,
nullptr);
146 EXPECT_EQ(bucket->key, 5);
147 EXPECT_EQ(bucket->status,
decltype(
tbl)::BUSY);
149 EXPECT_NO_THROW(
tbl.remove(5));
150 EXPECT_EQ(
tbl.search(5),
nullptr);
159 const int num_elements = 50;
160 for (
int i = 0; i < num_elements; ++i)
161 EXPECT_NE(
tbl.insert(i * 2),
nullptr);
163 EXPECT_EQ(
tbl.size(), num_elements);
167 for (
int i = 0; i < 10; ++i)
169 int non_existent_key = i * 2 + 1;
170 EXPECT_THROW(
tbl.remove(non_existent_key), std::domain_error);
174 EXPECT_EQ(
tbl.size(), num_elements)
175 <<
"Table size should not change after failed remove attempts";
178 for (
int i = 0; i < num_elements; ++i)
180 auto ptr =
tbl.search(i * 2);
181 EXPECT_NE(ptr,
nullptr)
182 <<
"Element " << i * 2 <<
" should still be in the table";
184 EXPECT_EQ(*ptr, i * 2);
188 for (
int i = 0; i < num_elements; ++i)
190 auto ptr =
tbl.search(i * 2);
191 ASSERT_NE(ptr,
nullptr);
192 EXPECT_NO_THROW(
tbl.remove(*ptr));
193 EXPECT_EQ(
tbl.size(), num_elements - i - 1);
196 EXPECT_TRUE(
tbl.is_empty());
205 for (
int i = 0; i < 20; ++i)
206 EXPECT_NE(
tbl.insert(i),
nullptr);
208 EXPECT_EQ(
tbl.size(), 20);
211 int external_key = 10;
212 EXPECT_NO_THROW(
tbl.remove(external_key));
213 EXPECT_EQ(
tbl.size(), 19);
214 EXPECT_EQ(
tbl.search(10),
nullptr);
217 for (
int i = 0; i < 20; ++i)
219 if (i == 10)
continue;
220 EXPECT_NE(
tbl.search(i),
nullptr) <<
"Element " << i <<
" should still exist";
230 for (
int i = 0; i < 20; ++i)
231 EXPECT_NE(
tbl.insert(i),
nullptr);
233 EXPECT_EQ(
tbl.size(), 20);
236 auto ptr =
tbl.search(10);
237 ASSERT_NE(ptr,
nullptr);
238 EXPECT_NO_THROW(
tbl.remove(*ptr));
239 EXPECT_EQ(
tbl.size(), 19);
240 EXPECT_EQ(
tbl.search(10),
nullptr);
250 const int num_elements = 15;
251 for (
int i = 0; i < num_elements; ++i)
252 EXPECT_NE(
tbl.insert(i),
nullptr);
254 EXPECT_EQ(
tbl.size(), num_elements);
257 for (
int i = 0; i < num_elements; ++i)
258 EXPECT_NE(
tbl.search(i),
nullptr) <<
"Element " << i <<
" not found";
261 for (
int i = 0; i < num_elements; i += 2)
263 auto ptr =
tbl.search(i);
264 ASSERT_NE(ptr,
nullptr);
269 for (
int i = 1; i < num_elements; i += 2)
270 EXPECT_NE(
tbl.search(i),
nullptr) <<
"Element " << i <<
" not found after removals";
273 for (
int i = 0; i < num_elements; i += 2)
274 EXPECT_EQ(
tbl.search(i),
nullptr) <<
"Element " << i <<
" should be removed";
283 for (
int i = 0; i < 50; ++i)
284 EXPECT_NE(
tbl.insert(i * 2),
nullptr);
286 const size_t original_capacity =
tbl.capacity();
287 const size_t original_size =
tbl.size();
290 for (
int attempt = 0; attempt < 100; ++attempt)
292 int non_existent = attempt * 2 + 1;
293 EXPECT_THROW(
tbl.remove(non_existent), std::domain_error);
297 EXPECT_EQ(
tbl.capacity(), original_capacity)
298 <<
"Capacity changed after failed remove attempts";
301 EXPECT_EQ(
tbl.size(), original_size);
304 for (
int i = 0; i < 50; ++i)
305 EXPECT_NE(
tbl.search(i * 2),
nullptr) <<
"Element " << i * 2 <<
" not found";
320 uniform_int_distribution<int> key_dist(0, 5000);
321 uniform_int_distribution<int> op_dist(0, 2);
323 const int num_operations = 8000;
325 for (
int i = 0; i < num_operations; ++i)
327 int key = key_dist(
rng);
328 int op = op_dist(
rng);
334 bool in_oracle =
oracle.count(key) > 0;
335 auto ptr =
tbl.insert(key);
338 EXPECT_FALSE(in_oracle) <<
"Insert succeeded but oracle had key " << key;
343 EXPECT_TRUE(in_oracle) <<
"Insert failed but oracle didn't have key " << key;
349 bool in_oracle =
oracle.count(key) > 0;
357 catch (
const domain_error &)
359 FAIL() <<
"Remove threw for key " << key <<
" that was in oracle";
364 EXPECT_THROW(
tbl.remove(key), domain_error);
370 auto ptr =
tbl.search(key);
371 bool in_oracle =
oracle.count(key) > 0;
372 EXPECT_EQ(ptr !=
nullptr, in_oracle) <<
"Search mismatch for key " << key;
374 EXPECT_EQ(*ptr, key);
379 ASSERT_EQ(
tbl.size(),
oracle.size()) <<
"Size mismatch at operation " << i;
384 ASSERT_NE(
tbl.search(key),
nullptr) <<
"Final: key " << key <<
" missing";
391 const size_t target =
tbl.capacity() - 1;
394 for (
size_t i = 0; i < target; ++i)
396 auto ptr =
tbl.insert(
static_cast<int>(i));
397 ASSERT_NE(ptr,
nullptr) <<
"Insert failed at i=" << i;
400 EXPECT_EQ(
tbl.size(), target);
403 for (
size_t i = 0; i < target; ++i)
404 ASSERT_NE(
tbl.search(
static_cast<int>(i)),
nullptr);
407 vector<int>
keys(target);
413 for (
size_t i = 0; i < target; ++i)
415 EXPECT_NO_THROW(
tbl.remove(
keys[i]));
416 EXPECT_EQ(
tbl.size(), target - i - 1);
419 EXPECT_TRUE(
tbl.is_empty());
426 auto bad_hash = [](
const int &) ->
size_t {
return 0; };
430 const int num_elements = 50;
431 for (
int i = 0; i < num_elements; ++i)
433 auto ptr =
tbl.insert(i);
434 ASSERT_NE(ptr,
nullptr) <<
"Insert failed at i=" << i;
437 EXPECT_EQ(
tbl.size(), num_elements);
440 for (
int i = 0; i < num_elements; ++i)
442 auto ptr =
tbl.search(i);
443 ASSERT_NE(ptr,
nullptr) <<
"Element " << i <<
" not found";
448 for (
int i = 0; i < num_elements; ++i)
450 EXPECT_NO_THROW(
tbl.remove(i));
451 EXPECT_EQ(
tbl.search(i),
nullptr);
454 EXPECT_TRUE(
tbl.is_empty());
462 const int cycles = 100;
463 const int elements_per_cycle = 50;
465 for (
int cycle = 0; cycle < cycles; ++cycle)
467 for (
int i = 0; i < elements_per_cycle; ++i)
469 int key = cycle * elements_per_cycle + i;
470 ASSERT_NE(
tbl.insert(key),
nullptr);
473 EXPECT_EQ(
tbl.size(), elements_per_cycle);
475 for (
int i = 0; i < elements_per_cycle; ++i)
477 int key = cycle * elements_per_cycle + i;
478 EXPECT_NO_THROW(
tbl.remove(key));
481 EXPECT_TRUE(
tbl.is_empty());
492 uniform_int_distribution<int> key_dist(0, 100000);
494 const int num_inserts = 5000;
495 for (
int i = 0; i < num_inserts; ++i)
497 int key = key_dist(
rng);
498 auto ptr =
tbl.insert(key);
499 if (
oracle.count(key) == 0 && ptr !=
nullptr)
507 ASSERT_NE(
tbl.search(key),
nullptr) <<
"Key " << key <<
" lost after resize";
518 uniform_int_distribution<int> key_dist(0, 1000);
519 uniform_real_distribution<double> prob_dist(0.0, 1.0);
521 const int num_ops = 5000;
523 for (
int i = 0; i < num_ops; ++i)
525 int key = key_dist(
rng);
526 double prob = prob_dist(
rng);
530 auto ptr =
tbl.insert(key);
543 catch (
const domain_error &)
545 FAIL() <<
"Remove threw for key " << key <<
" that was in oracle";
551 auto ptr =
tbl.search(key);
552 EXPECT_EQ(ptr !=
nullptr,
oracle.count(key) > 0);
569 uniform_int_distribution<int> key_dist(0, 50000);
571 const int num_inserts = 3000;
572 for (
int i = 0; i < num_inserts; ++i)
574 int key = key_dist(
rng);
575 auto ptr =
tbl.insert(key);
584 auto ptr =
tbl.search(key);
585 ASSERT_NE(ptr,
nullptr) <<
"Key " << key <<
" lost during resize";
601template <
typename HashTable>
605 for (
size_t i = 0; i <
tbl.capacity(); ++i)
607 switch (
tbl.table[i].status)
609 case HashTable::EMPTY: ++stats.
empty;
break;
610 case HashTable::BUSY: ++stats.
busy;
break;
611 case HashTable::DELETED: ++stats.
deleted;
break;
621 auto bad_hash = [](
const int &) ->
size_t {
return 0; };
624 tbl.set_with_resize(
false);
628 for (
int i = 0; i < 5; ++i)
629 ASSERT_NE(
tbl.insert(i),
nullptr);
632 EXPECT_EQ(before.busy, 5);
633 EXPECT_EQ(before.deleted, 0);
639 EXPECT_EQ(after.busy, 4);
640 EXPECT_EQ(after.deleted, 0) <<
"Last element should become EMPTY, not DELETED";
641 EXPECT_EQ(after.empty, before.empty + 1);
644 for (
int i = 0; i < 4; ++i)
645 EXPECT_NE(
tbl.search(i),
nullptr) <<
"Element " << i <<
" should still exist";
647 EXPECT_EQ(
tbl.search(4),
nullptr);
654 auto bad_hash = [](
const int &) ->
size_t {
return 0; };
657 tbl.set_with_resize(
false);
660 for (
int i = 0; i < 5; ++i)
661 ASSERT_NE(
tbl.insert(i),
nullptr);
668 EXPECT_EQ(mid_stats.busy, 3);
669 EXPECT_EQ(mid_stats.deleted, 2);
676 EXPECT_EQ(final_stats.busy, 2);
677 EXPECT_EQ(final_stats.deleted, 0) <<
"All trailing DELETED should become EMPTY";
680 EXPECT_NE(
tbl.search(0),
nullptr);
681 EXPECT_NE(
tbl.search(1),
nullptr);
682 EXPECT_EQ(
tbl.search(2),
nullptr);
683 EXPECT_EQ(
tbl.search(3),
nullptr);
684 EXPECT_EQ(
tbl.search(4),
nullptr);
690 auto bad_hash = [](
const int &) ->
size_t {
return 0; };
693 tbl.set_with_resize(
false);
696 for (
int i = 0; i < 5; ++i)
697 ASSERT_NE(
tbl.insert(i),
nullptr);
703 EXPECT_EQ(stats.busy, 4);
704 EXPECT_EQ(stats.deleted, 1) <<
"Middle element should stay DELETED";
707 for (
int i = 0; i < 5; ++i)
710 EXPECT_EQ(
tbl.search(i),
nullptr);
712 EXPECT_NE(
tbl.search(i),
nullptr);
722 const int cycles = 50;
723 const int elements = 30;
725 for (
int cycle = 0; cycle < cycles; ++cycle)
728 for (
int i = 0; i < elements; ++i)
729 tbl.insert(cycle * 1000 + i);
732 for (
int i = 0; i < elements; ++i)
733 tbl.remove(cycle * 1000 + i);
738 EXPECT_EQ(stats.busy, 0);
739 EXPECT_EQ(stats.deleted, 0) <<
"Should have no DELETED after complete removal";
740 EXPECT_TRUE(
tbl.is_empty());
751 auto near_end_hash = [](
const int &
k) ->
size_t {
752 return static_cast<size_t>(
k + 15);
758 for (
int i = 0; i < 5; ++i)
759 ASSERT_NE(tbl2.
insert(i),
nullptr);
761 EXPECT_EQ(tbl2.
size(), 5);
764 for (
int i = 4; i >= 0; --i)
766 EXPECT_NO_THROW(tbl2.
remove(i));
770 EXPECT_EQ(stats.deleted, 0) <<
"Wrap-around cleanup should leave no DELETED";
779 tbl.set_with_resize(
false);
783 uniform_int_distribution<int> key_dist(0, 200);
784 uniform_real_distribution<double> op_dist(0.0, 1.0);
786 const int num_ops = 5000;
788 for (
int i = 0; i < num_ops; ++i)
790 int key = key_dist(
rng);
791 double op = op_dist(
rng);
795 auto ptr =
tbl.insert(key);
796 if (ptr)
oracle.insert(key);
798 else if (
oracle.count(key))
809 double deleted_ratio =
static_cast<double>(stats.deleted) /
tbl.capacity();
810 EXPECT_LT(deleted_ratio, 0.1)
811 <<
"DELETED ratio should be low with cleanup. Got "
812 << stats.deleted <<
"/" <<
tbl.capacity();
817 EXPECT_NE(
tbl.search(key),
nullptr);
827 for (
int i = 0; i < 50; ++i)
832 EXPECT_EQ(
copy.size(), original.
size());
836 for (
int i = 0; i < 50; ++i)
838 EXPECT_NE(original.
search(i),
nullptr);
839 EXPECT_NE(
copy.search(i),
nullptr);
844 EXPECT_EQ(
copy.search(25),
nullptr);
845 EXPECT_NE(original.
search(25),
nullptr);
851 for (
int i = 0; i < 50; ++i)
854 const size_t orig_size = original.
size();
855 const size_t orig_cap = original.
capacity();
859 EXPECT_EQ(moved.
size(), orig_size);
860 EXPECT_EQ(moved.
capacity(), orig_cap);
863 for (
int i = 0; i < 50; ++i)
864 EXPECT_NE(moved.
search(i),
nullptr);
870 for (
int i = 0; i < 50; ++i)
878 EXPECT_EQ(
copy.size(), original.
size());
880 for (
int i = 0; i < 50; ++i)
881 EXPECT_NE(
copy.search(i),
nullptr);
883 EXPECT_EQ(
copy.search(999),
nullptr);
889 for (
int i = 0; i < 50; ++i)
892 const size_t orig_size = original.
size();
897 target = std::move(original);
899 EXPECT_EQ(target.
size(), orig_size);
901 for (
int i = 0; i < 50; ++i)
902 EXPECT_NE(target.
search(i),
nullptr);
908 for (
int i = 0; i < 50; ++i)
913 EXPECT_EQ(
tbl.size(), 50);
914 for (
int i = 0; i < 50; ++i)
915 EXPECT_NE(
tbl.search(i),
nullptr);
924 auto bad_hash = [](
const int &) ->
size_t {
return 0; };
927 tbl.set_with_resize(
false);
930 for (
int i = 0; i < 5; ++i)
937 EXPECT_EQ(before.deleted, 1);
943 EXPECT_EQ(after.deleted, 0) <<
"DELETED slot should be reused";
944 EXPECT_EQ(after.busy, 5);
947 EXPECT_NE(
tbl.search(0),
nullptr);
948 EXPECT_NE(
tbl.search(1),
nullptr);
949 EXPECT_EQ(
tbl.search(2),
nullptr);
950 EXPECT_NE(
tbl.search(3),
nullptr);
951 EXPECT_NE(
tbl.search(4),
nullptr);
952 EXPECT_NE(
tbl.search(100),
nullptr);
963 auto ptr =
tbl.search_or_insert(42);
964 ASSERT_NE(ptr,
nullptr);
966 EXPECT_EQ(
tbl.size(), 1);
974 auto ptr =
tbl.search_or_insert(42);
975 ASSERT_NE(ptr,
nullptr);
977 EXPECT_EQ(
tbl.size(), 1);
984 auto [ptr, existed] =
tbl.contains_or_insert(42);
985 ASSERT_NE(ptr,
nullptr);
987 EXPECT_FALSE(existed);
988 EXPECT_EQ(
tbl.size(), 1);
996 auto [ptr, existed] =
tbl.contains_or_insert(42);
997 ASSERT_NE(ptr,
nullptr);
999 EXPECT_TRUE(existed);
1000 EXPECT_EQ(
tbl.size(), 1);
1012 for (
int i = 0; i < 50; ++i)
1019 for (
int i = 0; i < 50; i += 2)
1033 EXPECT_EQ(after.deleted, 0) <<
"Rehash should eliminate all DELETED";
1034 EXPECT_EQ(after.busy,
oracle.size());
1038 EXPECT_NE(
tbl.search(key),
nullptr);
1045 for (
int i = 0; i < 30; ++i)
1048 const size_t old_cap =
tbl.capacity();
1051 EXPECT_GT(
tbl.capacity(), old_cap);
1052 EXPECT_EQ(
tbl.size(), 30);
1054 for (
int i = 0; i < 30; ++i)
1055 EXPECT_NE(
tbl.search(i),
nullptr);
1062 for (
int i = 0; i < 30; ++i)
1067 EXPECT_EQ(
tbl.size(), 30);
1069 for (
int i = 0; i < 30; ++i)
1070 EXPECT_NE(
tbl.search(i),
nullptr);
1081 EXPECT_TRUE(
tbl.is_empty());
1082 EXPECT_EQ(
tbl.size(), 0);
1083 EXPECT_EQ(
tbl.search(42),
nullptr);
1084 EXPECT_FALSE(
tbl.has(42));
1085 EXPECT_FALSE(
tbl.contains(42));
1086 EXPECT_THROW(
tbl.remove(42), std::domain_error);
1094 EXPECT_EQ(
tbl.size(), 1);
1095 EXPECT_NE(
tbl.search(42),
nullptr);
1098 EXPECT_EQ(
tbl.size(), 0);
1099 EXPECT_TRUE(
tbl.is_empty());
1100 EXPECT_EQ(
tbl.search(42),
nullptr);
1104 EXPECT_EQ(stats.deleted, 0);
1111 auto first =
tbl.insert(42);
1112 ASSERT_NE(first,
nullptr);
1114 auto second =
tbl.insert(42);
1115 EXPECT_EQ(second,
nullptr) <<
"Duplicate insert should return nullptr";
1117 EXPECT_EQ(
tbl.size(), 1);
1124 EXPECT_FALSE(
tbl.has(42));
1125 EXPECT_FALSE(
tbl.contains(42));
1129 EXPECT_TRUE(
tbl.has(42));
1130 EXPECT_TRUE(
tbl.contains(42));
1131 EXPECT_FALSE(
tbl.has(43));
1132 EXPECT_FALSE(
tbl.contains(43));
1141 int& ref =
tbl.find(42);
1145 EXPECT_THROW(
tbl.find(999), std::domain_error);
1157 for (
int i = 0; i < 50; ++i)
1164 for (
auto it =
tbl.get_it(); it.has_curr(); it.next())
1165 visited.insert(it.get_curr());
1167 EXPECT_EQ(visited,
oracle);
1174 auto it =
tbl.get_it();
1175 EXPECT_FALSE(it.has_curr());
1183 auto it =
tbl.get_it();
1184 ASSERT_TRUE(it.has_curr());
1185 EXPECT_EQ(it.get_curr(), 42);
1188 EXPECT_FALSE(it.has_curr());
1195 for (
int i = 0; i < 10; ++i)
1199 auto it =
tbl.get_it();
1200 while (it.has_curr())
1203 EXPECT_TRUE(
tbl.is_empty());
1211 auto bad_hash = [](
const int &) ->
size_t {
return 0; };
1214 for (
int i = 0; i < 10; ++i)
1215 ASSERT_NE(
tbl.insert(i),
nullptr);
1217 auto it =
tbl.get_it();
1218 for (
size_t removed = 1; it.has_curr(); ++removed)
1221 EXPECT_EQ(
tbl.size(), 10 - removed);
1222 EXPECT_EQ(
tbl.stats().num_deleted, removed < 10 ? removed : 0);
1225 EXPECT_TRUE(
tbl.is_empty());
1226 EXPECT_EQ(
tbl.stats().num_empty,
tbl.capacity());
1228 for (
int i = 0; i < 10; ++i)
1229 ASSERT_NE(
tbl.insert(i),
nullptr);
1230 for (
int i = 0; i < 10; ++i)
1231 EXPECT_TRUE(
tbl.contains(i)) << i;
1240 auto bad_hash = [](
const int &) ->
size_t {
return 0; };
1244 for (
int i = 0; i < 10; ++i)
1252 auto stats =
tbl.stats();
1254 EXPECT_EQ(stats.num_busy, 7);
1256 EXPECT_EQ(stats.num_busy + stats.num_deleted + stats.num_empty,
tbl.capacity());
1266 for (
int i = 0; i < 10; ++i)
1270 tbl.for_each([&
sum](
int x) {
sum += x; });
1278 for (
int i = 0; i < 10; ++i)
1281 EXPECT_TRUE(
tbl.all([](
int x) { return x % 2 == 0; }));
1282 EXPECT_FALSE(
tbl.all([](
int x) { return x > 5; }));
1288 for (
int i = 0; i < 10; ++i)
1291 EXPECT_TRUE(
tbl.exists([](
int x) { return x == 5; }));
1292 EXPECT_FALSE(
tbl.exists([](
int x) { return x == 100; }));
1298 for (
int i = 0; i < 10; ++i)
1301 auto evens =
tbl.filter([](
int x) {
return x % 2 == 0; });
1303 EXPECT_EQ(evens.size(), 5);
Open addressing hash table with linear probing collision resolution.
Key * search(const Key &key) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
void remove(const Key &key)
Remove the key referenced by key.
constexpr size_t size() const noexcept
Returns the number of entries in the table.
constexpr size_t capacity() const noexcept
Returns the current capacity of the table.
constexpr bool is_empty() const noexcept
Checks if the table is empty.
Key * insert(const Key &key)
Inserts a key into the hash table (copy version).
MapOLhash< int, Foo > tbl
Main namespace for Aleph-w library functions.
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
void iota(C &container, typename C::Item_Type start)
Fill all elements of a container with unit-step sequential values.
size_t dft_hash_fct(const Key &key) noexcept
Primary default hash: best speed/quality trade-off.
auto shuffle(const C< T > &c)
Randomly shuffle a sequence.
std::string to_string(const time_t t, const std::string &format)
Format a time_t value into a string using format.
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
size_t my_hash(const MyRecord &r) noexcept
BucketStats count_bucket_states(const HashTable &tbl)
bool operator()(const MyRecord &r1, const MyRecord &r2) const noexcept
bool operator==(const MyRecord &r) const noexcept
MyRecord(size_t k, const string &v)
Open addressing hash table with linear probing.