37# include <gtest/gtest.h>
47using namespace testing;
54 EXPECT_TRUE(
tbl.is_empty());
55 EXPECT_EQ(
tbl.size(), 0);
57 const size_t cap =
tbl.capacity();
58 for (
size_t i = 0; i < cap; ++i)
60 EXPECT_EQ(
tbl.size(), i);
61 EXPECT_NE(
tbl.insert(i),
nullptr);
62 EXPECT_EQ(
tbl.size(), i + 1);
63 EXPECT_FALSE(
tbl.is_empty());
66 for (
size_t i = 0; i <
tbl.size(); ++i)
68 ASSERT_NE(
tbl.search(i),
nullptr);
69 auto ptr =
tbl.search(i);
71 EXPECT_FALSE(
tbl.is_empty());
74 for (
size_t i = 0, n =
tbl.size(); i < n; ++i)
76 auto ptr =
tbl.search(i);
79 EXPECT_EQ(
tbl.size(), n - i - 1);
80 EXPECT_EQ(
tbl.search(i),
nullptr);
81 EXPECT_FALSE(
tbl.contains(i));
84 EXPECT_EQ(
tbl.size(), 0);
85 EXPECT_TRUE(
tbl.is_empty());
99 return r1.key == r2.key;
120 EXPECT_EQ(
tbl.size(), 0);
121 EXPECT_TRUE(
tbl.is_empty());
123 for (
size_t i = 0; i < 100; ++i)
125 EXPECT_EQ(
tbl.size(), i);
127 EXPECT_EQ(
tbl.size(), i + 1);
129 EXPECT_NE(ptr,
nullptr);
130 EXPECT_EQ(ptr->key, i);
134 for (
size_t i = 0, n =
tbl.size(); i < n; ++i)
136 auto ptr =
tbl.search(i);
139 EXPECT_EQ(
tbl.size(), n - i - 1);
140 EXPECT_EQ(
tbl.search(i),
nullptr);
149 ASSERT_NE(ptr,
nullptr);
151 auto *bucket =
decltype(
tbl)::key_to_bucket(ptr);
152 ASSERT_NE(bucket,
nullptr);
153 EXPECT_EQ(bucket->key, 5);
154 EXPECT_EQ(bucket->status,
decltype(
tbl)::BUSY);
156 EXPECT_NO_THROW(
tbl.remove(5));
157 EXPECT_EQ(
tbl.search(5),
nullptr);
168 const int num_elements = 50;
169 for (
int i = 0; i < num_elements; ++i)
170 EXPECT_NE(
tbl.insert(i * 2),
nullptr);
172 EXPECT_EQ(
tbl.size(), num_elements);
176 for (
int i = 0; i < 10; ++i)
178 int non_existent_key = i * 2 + 1;
179 EXPECT_THROW(
tbl.remove(non_existent_key), std::domain_error);
183 EXPECT_EQ(
tbl.size(), num_elements)
184 <<
"Table size should not change after failed remove attempts";
187 for (
int i = 0; i < num_elements; ++i)
189 auto ptr =
tbl.search(i * 2);
190 EXPECT_NE(ptr,
nullptr)
191 <<
"Element " << i * 2 <<
" should still be in the table";
193 EXPECT_EQ(*ptr, i * 2);
197 for (
int i = 0; i < num_elements; ++i)
199 auto ptr =
tbl.search(i * 2);
200 ASSERT_NE(ptr,
nullptr);
201 EXPECT_NO_THROW(
tbl.remove(*ptr));
202 EXPECT_EQ(
tbl.size(), num_elements - i - 1);
205 EXPECT_TRUE(
tbl.is_empty());
214 for (
int i = 0; i < 20; ++i)
215 EXPECT_NE(
tbl.insert(i),
nullptr);
217 EXPECT_EQ(
tbl.size(), 20);
220 int external_key = 10;
221 EXPECT_NO_THROW(
tbl.remove(external_key));
222 EXPECT_EQ(
tbl.size(), 19);
223 EXPECT_EQ(
tbl.search(10),
nullptr);
226 for (
int i = 0; i < 20; ++i)
228 if (i == 10)
continue;
229 EXPECT_NE(
tbl.search(i),
nullptr) <<
"Element " << i <<
" should still exist";
239 for (
int i = 0; i < 20; ++i)
240 EXPECT_NE(
tbl.insert(i),
nullptr);
242 EXPECT_EQ(
tbl.size(), 20);
245 auto ptr =
tbl.search(10);
246 ASSERT_NE(ptr,
nullptr);
247 EXPECT_NO_THROW(
tbl.remove(*ptr));
248 EXPECT_EQ(
tbl.size(), 19);
249 EXPECT_EQ(
tbl.search(10),
nullptr);
260 for (
int i = 0; i < 50; ++i)
261 EXPECT_NE(
tbl.insert(i * 2),
nullptr);
263 const size_t original_capacity =
tbl.capacity();
264 const size_t original_size =
tbl.size();
268 for (
int attempt = 0; attempt < 100; ++attempt)
270 int non_existent = attempt * 2 + 1;
271 EXPECT_THROW(
tbl.remove(non_existent), std::domain_error);
275 EXPECT_EQ(
tbl.capacity(), original_capacity)
276 <<
"Capacity changed - possible unnecessary rehash on failed remove";
279 EXPECT_EQ(
tbl.size(), original_size);
282 for (
int i = 0; i < 50; ++i)
283 EXPECT_NE(
tbl.search(i * 2),
nullptr) <<
"Element " << i * 2 <<
" not found";
298 uniform_int_distribution<int> key_dist(0, 5000);
299 uniform_int_distribution<int> op_dist(0, 2);
301 const int num_operations = 8000;
303 for (
int i = 0; i < num_operations; ++i)
305 int key = key_dist(
rng);
306 int op = op_dist(
rng);
312 bool in_oracle =
oracle.count(key) > 0;
313 auto ptr =
tbl.insert(key);
316 EXPECT_FALSE(in_oracle) <<
"Insert succeeded for key " << key
317 <<
" but oracle already had it";
322 EXPECT_TRUE(in_oracle) <<
"Insert failed for key " << key
323 <<
" but oracle didn't have it";
329 bool in_oracle =
oracle.count(key) > 0;
337 catch (
const domain_error &)
339 FAIL() <<
"Remove threw for key " << key <<
" that was in oracle";
344 EXPECT_THROW(
tbl.remove(key), domain_error);
350 auto ptr =
tbl.search(key);
351 bool in_oracle =
oracle.count(key) > 0;
352 EXPECT_EQ(ptr !=
nullptr, in_oracle)
353 <<
"Search mismatch for key " << key;
355 EXPECT_EQ(*ptr, key);
361 <<
"Size mismatch at operation " << i <<
", key=" << key;
367 auto ptr =
tbl.search(key);
368 ASSERT_NE(ptr,
nullptr) <<
"Final check: key " << key <<
" missing";
376 const size_t target =
tbl.capacity() - 1;
379 for (
size_t i = 0; i < target; ++i)
381 auto ptr =
tbl.insert(
static_cast<int>(i));
382 ASSERT_NE(ptr,
nullptr) <<
"Insert failed at i=" << i;
385 EXPECT_EQ(
tbl.size(), target);
388 for (
size_t i = 0; i < target; ++i)
390 ASSERT_NE(
tbl.search(
static_cast<int>(i)),
nullptr)
391 <<
"Element " << i <<
" not found after fill";
395 vector<int>
keys(target);
401 for (
size_t i = 0; i < target; ++i)
403 EXPECT_NO_THROW(
tbl.remove(
keys[i])) <<
"Remove failed for key " <<
keys[i];
404 EXPECT_EQ(
tbl.size(), target - i - 1);
407 EXPECT_TRUE(
tbl.is_empty());
414 auto bad_hash = [](
const int &) ->
size_t {
return 42; };
419 const int num_elements = 50;
420 for (
int i = 0; i < num_elements; ++i)
422 auto ptr =
tbl.insert(i);
423 ASSERT_NE(ptr,
nullptr) <<
"Insert failed at i=" << i <<
" with bad hash";
426 EXPECT_EQ(
tbl.size(), num_elements);
429 for (
int i = 0; i < num_elements; ++i)
431 auto ptr =
tbl.search(i);
432 ASSERT_NE(ptr,
nullptr) <<
"Element " << i <<
" not found with collision";
437 for (
int i = num_elements - 1; i >= 0; --i)
439 EXPECT_NO_THROW(
tbl.remove(i));
440 EXPECT_EQ(
tbl.search(i),
nullptr);
443 EXPECT_TRUE(
tbl.is_empty());
451 const int cycles = 100;
452 const int elements_per_cycle = 50;
454 for (
int cycle = 0; cycle < cycles; ++cycle)
457 for (
int i = 0; i < elements_per_cycle; ++i)
459 int key = cycle * elements_per_cycle + i;
460 auto ptr =
tbl.insert(key);
461 ASSERT_NE(ptr,
nullptr) <<
"Insert failed at cycle " << cycle <<
", i=" << i;
464 EXPECT_EQ(
tbl.size(), elements_per_cycle);
467 for (
int i = 0; i < elements_per_cycle; ++i)
469 int key = cycle * elements_per_cycle + i;
470 EXPECT_NO_THROW(
tbl.remove(key));
473 EXPECT_TRUE(
tbl.is_empty());
485 uniform_int_distribution<int> key_dist(0, 100000);
488 const int num_inserts = 5000;
489 for (
int i = 0; i < num_inserts; ++i)
491 int key = key_dist(
rng);
492 auto ptr =
tbl.insert(key);
493 if (
oracle.count(key) == 0 && ptr !=
nullptr)
502 auto ptr =
tbl.search(key);
503 ASSERT_NE(ptr,
nullptr) <<
"Key " << key <<
" lost after resize";
507 size_t to_remove =
oracle.size() / 2;
509 for (
size_t i = 0; i < to_remove; ++i, ++it)
511 EXPECT_NO_THROW(
tbl.remove(*it));
520 ASSERT_NE(
tbl.search(key),
nullptr) <<
"Key " << key <<
" missing after partial remove";
532 uniform_int_distribution<int> key_dist(0, 1000);
533 uniform_real_distribution<double> prob_dist(0.0, 1.0);
535 const int num_ops = 5000;
537 for (
int i = 0; i < num_ops; ++i)
539 int key = key_dist(
rng);
540 double prob = prob_dist(
rng);
544 auto ptr =
tbl.insert(key);
557 catch (
const domain_error &)
559 FAIL() <<
"Remove threw for key " << key <<
" that was in oracle";
565 auto ptr =
tbl.search(key);
566 bool in_oracle =
oracle.count(key) > 0;
567 EXPECT_EQ(ptr !=
nullptr, in_oracle)
568 <<
"Search mismatch for key " << key;
573 ASSERT_EQ(
tbl.size(),
oracle.size()) <<
"Size mismatch at i=" << i;
588 uniform_int_distribution<int> key_dist(0, 50000);
591 const int num_inserts = 3000;
592 for (
int i = 0; i < num_inserts; ++i)
594 int key = key_dist(
rng);
595 auto ptr =
tbl.insert(key);
606 auto ptr =
tbl.search(key);
607 ASSERT_NE(ptr,
nullptr) <<
"Key " << key <<
" lost during resize";
608 EXPECT_EQ(*ptr, key);
613 size_t to_remove =
oracle.size() / 3;
614 for (
size_t i = 0; i < to_remove && it !=
oracle.end(); ++i)
626 ASSERT_NE(
tbl.search(key),
nullptr);
636 uniform_int_distribution<int> len_dist(1, 50);
637 uniform_int_distribution<int> char_dist(
'a',
'z');
640 int len = len_dist(
rng);
643 for (
int i = 0; i < len; ++i)
644 s +=
static_cast<char>(char_dist(
rng));
648 const int num_ops = 2000;
650 for (
int i = 0; i < num_ops; ++i)
654 if (
oracle.count(key) == 0)
656 auto ptr =
tbl.insert(key);
671 for (
const auto & key :
oracle)
673 auto ptr =
tbl.search(key);
674 ASSERT_NE(ptr,
nullptr) <<
"String key missing: " << key;
684 for (
int i = 0; i < 30; ++i)
685 EXPECT_NE(
tbl.insert(i),
nullptr);
688 for (
int i = 0; i < 30; i += 2)
691 const size_t size_after_removes =
tbl.size();
694 for (
int i = 1; i < 30; i += 2)
696 auto ptr =
tbl.search_or_insert(i);
697 ASSERT_NE(ptr,
nullptr);
700 EXPECT_EQ(
tbl.size(), size_after_removes);
703 for (
int i = 0; i < 30; i += 2)
705 const size_t old_size =
tbl.size();
706 auto ptr =
tbl.search_or_insert(i);
707 ASSERT_NE(ptr,
nullptr);
709 EXPECT_EQ(
tbl.size(), old_size + 1);
713 for (
int i = 0; i < 30; ++i)
715 auto ptr =
tbl.search(i);
716 ASSERT_NE(ptr,
nullptr) <<
"Key " << i <<
" not found";
724 auto bad_hash = [](
const int &) ->
size_t {
return 7; };
729 for (
int i = 0; i < 20; ++i)
730 EXPECT_NE(
tbl.insert(i),
nullptr);
732 for (
int i = 0; i < 20; i += 3)
736 for (
int i = 20; i < 30; ++i)
738 auto [ptr, existed] =
tbl.contains_or_insert(i);
739 ASSERT_NE(ptr,
nullptr);
740 EXPECT_FALSE(existed) <<
"Key " << i <<
" should not have existed";
745 for (
int i = 20; i < 30; ++i)
747 auto [ptr, existed] =
tbl.contains_or_insert(i);
748 ASSERT_NE(ptr,
nullptr);
749 EXPECT_TRUE(existed) <<
"Key " << i <<
" should have existed";
759 std::mt19937 gen(54321);
760 std::uniform_int_distribution<> key_dist(0, 500);
761 std::uniform_int_distribution<> op_dist(0, 2);
763 for (
int iter = 0; iter < 5000; ++iter)
765 int key = key_dist(gen);
766 int op = op_dist(gen);
770 auto ptr =
tbl.search_or_insert(key);
771 ASSERT_NE(ptr,
nullptr) <<
"search_or_insert returned nullptr for key " << key;
772 EXPECT_EQ(*ptr, key);
775 auto verify_ptr =
tbl.search(key);
776 ASSERT_NE(verify_ptr,
nullptr)
777 <<
"Key " << key <<
" not found immediately after search_or_insert at iter " << iter;
779 else if (op == 1 &&
oracle.count(key))
782 auto pre_ptr =
tbl.search(key);
783 ASSERT_NE(pre_ptr,
nullptr)
784 <<
"Key " << key <<
" should exist before removal at iter " << iter
785 <<
", oracle.count=" <<
oracle.count(key) <<
", tbl.size=" <<
tbl.size();
791 auto ptr =
tbl.search(key);
793 ASSERT_NE(ptr,
nullptr) <<
"Key " << key <<
" should exist at iter " << iter;
795 EXPECT_EQ(ptr,
nullptr);
799 <<
"Size mismatch at iter " << iter <<
": tbl=" <<
tbl.size() <<
", oracle=" <<
oracle.size();
805 auto ptr =
tbl.search(key);
806 ASSERT_NE(ptr,
nullptr) <<
"Key " << key <<
" missing";
815 std::mt19937 gen(54321);
816 std::uniform_int_distribution<> key_dist(0, 500);
817 std::uniform_int_distribution<> op_dist(0, 2);
820 for (
int iter = 0; iter <= 705; ++iter)
822 int key = key_dist(gen);
823 int op = op_dist(gen);
828 auto p =
tbl.search(
k);
829 ASSERT_NE(p,
nullptr)
830 <<
"Pre-op check: Key " <<
k <<
" missing at iter " << iter
831 <<
" (about to do op " << op <<
" on key " << key <<
")";
836 bool existed_before =
oracle.count(key) > 0;
837 size_t size_before =
tbl.size();
838 auto ptr =
tbl.search_or_insert(key);
839 ASSERT_NE(ptr,
nullptr) <<
"search_or_insert returned nullptr at iter " << iter;
840 EXPECT_EQ(*ptr, key);
844 EXPECT_EQ(
tbl.size(), size_before + 1)
845 <<
"Size should increase for new key at iter " << iter;
847 else if (op == 1 &&
oracle.count(key))
854 <<
"Size mismatch at iter " << iter;
865 for (
int i = 0; i < 50; ++i)
870 EXPECT_EQ(
copy.size(), original.
size());
873 for (
int i = 0; i < 50; ++i)
875 EXPECT_NE(original.
search(i),
nullptr);
876 EXPECT_NE(
copy.search(i),
nullptr);
880 EXPECT_EQ(
copy.search(25),
nullptr);
881 EXPECT_NE(original.
search(25),
nullptr);
887 for (
int i = 0; i < 50; ++i)
890 const size_t orig_size = original.
size();
891 const size_t orig_cap = original.
capacity();
895 EXPECT_EQ(moved.
size(), orig_size);
896 EXPECT_EQ(moved.
capacity(), orig_cap);
898 for (
int i = 0; i < 50; ++i)
899 EXPECT_NE(moved.
search(i),
nullptr);
905 for (
int i = 0; i < 50; ++i)
913 EXPECT_EQ(
copy.size(), original.
size());
915 for (
int i = 0; i < 50; ++i)
916 EXPECT_NE(
copy.search(i),
nullptr);
918 EXPECT_EQ(
copy.search(999),
nullptr);
924 for (
int i = 0; i < 50; ++i)
927 const size_t orig_size = original.
size();
932 target = std::move(original);
934 EXPECT_EQ(target.
size(), orig_size);
936 for (
int i = 0; i < 50; ++i)
937 EXPECT_NE(target.
search(i),
nullptr);
943 for (
int i = 0; i < 50; ++i)
948 EXPECT_EQ(
tbl.size(), 50);
949 for (
int i = 0; i < 50; ++i)
950 EXPECT_NE(
tbl.search(i),
nullptr);
961 EXPECT_TRUE(
tbl.is_empty());
962 EXPECT_EQ(
tbl.size(), 0);
963 EXPECT_EQ(
tbl.search(42),
nullptr);
964 EXPECT_FALSE(
tbl.has(42));
965 EXPECT_FALSE(
tbl.contains(42));
966 EXPECT_THROW(
tbl.remove(42), std::domain_error);
974 EXPECT_EQ(
tbl.size(), 1);
975 EXPECT_NE(
tbl.search(42),
nullptr);
978 EXPECT_EQ(
tbl.size(), 0);
979 EXPECT_TRUE(
tbl.is_empty());
980 EXPECT_EQ(
tbl.search(42),
nullptr);
987 auto first =
tbl.insert(42);
988 ASSERT_NE(first,
nullptr);
990 auto second =
tbl.insert(42);
991 EXPECT_EQ(second,
nullptr);
993 EXPECT_EQ(
tbl.size(), 1);
1000 EXPECT_FALSE(
tbl.has(42));
1001 EXPECT_FALSE(
tbl.contains(42));
1005 EXPECT_TRUE(
tbl.has(42));
1006 EXPECT_TRUE(
tbl.contains(42));
1007 EXPECT_FALSE(
tbl.has(43));
1008 EXPECT_FALSE(
tbl.contains(43));
1017 int& ref =
tbl.find(42);
1021 EXPECT_THROW(
tbl.find(999), std::domain_error);
1033 for (
int i = 0; i < 50; ++i)
1039 for (
int i = 0; i < 50; i += 2)
1050 EXPECT_NE(
tbl.search(key),
nullptr);
1057 for (
int i = 0; i < 30; ++i)
1060 const size_t old_cap =
tbl.capacity();
1063 EXPECT_GT(
tbl.capacity(), old_cap);
1064 EXPECT_EQ(
tbl.size(), 30);
1066 for (
int i = 0; i < 30; ++i)
1067 EXPECT_NE(
tbl.search(i),
nullptr);
1074 for (
int i = 0; i < 30; ++i)
1079 EXPECT_EQ(
tbl.size(), 30);
1081 for (
int i = 0; i < 30; ++i)
1082 EXPECT_NE(
tbl.search(i),
nullptr);
1094 for (
int i = 0; i < 50; ++i)
1101 for (
auto it =
tbl.get_it(); it.has_curr(); it.next())
1102 visited.insert(it.get_curr());
1104 EXPECT_EQ(visited,
oracle);
1111 auto it =
tbl.get_it();
1112 EXPECT_FALSE(it.has_curr());
1120 auto it =
tbl.get_it();
1121 ASSERT_TRUE(it.has_curr());
1122 EXPECT_EQ(it.get_curr(), 42);
1125 EXPECT_FALSE(it.has_curr());
1132 for (
int i = 0; i < 10; ++i)
1135 auto it =
tbl.get_it();
1136 while (it.has_curr())
1139 EXPECT_TRUE(
tbl.is_empty());
1154template <
typename HashTable>
1158 for (
size_t i = 0; i <
tbl.capacity(); ++i)
1160 switch (
tbl.table[i].status)
1162 case HashTable::EMPTY: ++stats.
empty;
break;
1163 case HashTable::BUSY: ++stats.
busy;
break;
1164 case HashTable::DELETED: ++stats.
deleted;
break;
1173 auto bad_hash = [](
const int &) ->
size_t {
return 0; };
1177 for (
int i = 0; i < 5; ++i)
1181 EXPECT_EQ(before.busy, 5);
1182 EXPECT_EQ(before.deleted, 0);
1188 EXPECT_EQ(after.busy, 4);
1190 EXPECT_EQ(after.deleted, 0) <<
"Last element should become EMPTY via probe_counter";
1192 for (
int i = 0; i < 4; ++i)
1193 EXPECT_NE(
tbl.search(i),
nullptr);
1194 EXPECT_EQ(
tbl.search(4),
nullptr);
1199 auto bad_hash = [](
const int &) ->
size_t {
return 0; };
1202 tbl.set_with_resize(
false);
1204 for (
int i = 0; i < 5; ++i)
1211 EXPECT_EQ(stats.busy, 4);
1212 EXPECT_EQ(stats.deleted, 1) <<
"Middle should stay DELETED";
1214 for (
int i = 0; i < 5; ++i)
1217 EXPECT_EQ(
tbl.search(i),
nullptr);
1219 EXPECT_NE(
tbl.search(i),
nullptr);
1225 auto bad_hash = [](
const int &) ->
size_t {
return 0; };
1228 for (
int i = 0; i < 5; ++i)
1232 for (
int i = 4; i >= 0; --i)
1236 EXPECT_EQ(stats.busy, 0);
1237 EXPECT_EQ(stats.deleted, 0) <<
"All should become EMPTY when removed in reverse";
1238 EXPECT_TRUE(
tbl.is_empty());
1248 for (
int i = 0; i < 10; ++i)
1252 tbl.for_each([&
sum](
int x) {
sum += x; });
1260 for (
int i = 0; i < 10; ++i)
1263 EXPECT_TRUE(
tbl.all([](
int x) { return x % 2 == 0; }));
1264 EXPECT_FALSE(
tbl.all([](
int x) { return x > 5; }));
1270 for (
int i = 0; i < 10; ++i)
1273 EXPECT_TRUE(
tbl.exists([](
int x) { return x == 5; }));
1274 EXPECT_FALSE(
tbl.exists([](
int x) { return x == 100; }));
1280 for (
int i = 0; i < 10; ++i)
1283 auto evens =
tbl.filter([](
int x) {
return x % 2 == 0; });
1285 EXPECT_EQ(evens.size(), 5);
static string random_string(std::mt19937 &rng, size_t len)
Open addressing hash table with double hashing collision resolution.
Key * search(const Key &key) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
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.
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.
size_t snd_hash_fct(const Key &key) noexcept
Secondary default hash: different distribution from dft_hash_fct.
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 snd_hash(const MyRecord &r) noexcept
size_t fst_hast(const MyRecord &r) noexcept
ODhashBucketStats count_odhash_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 double hashing.