From 8c2d84b138034db99d85b921bdac62f5f85a6a81 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 1 Apr 2022 14:20:10 -0400 Subject: [PATCH] Better fix for iussue #136 --- examples/basic.cc | 7 ++++++- parallel_hashmap/phmap.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/basic.cc b/examples/basic.cc index f83d6fb..2b7f050 100644 --- a/examples/basic.cc +++ b/examples/basic.cc @@ -7,7 +7,12 @@ using phmap::flat_hash_map; int main() { // Create an unordered_map of three strings (that map to strings) - flat_hash_map email; + flat_hash_map email = + { + { "tom", "tom@gmail.com"}, + { "jeff", "jk@gmail.com"}, + { "jim", "jimg@microsoft.com"} + }; // Iterate and print keys and values for (const auto& n : email) diff --git a/parallel_hashmap/phmap.h b/parallel_hashmap/phmap.h index 48573b9..f5db1cb 100644 --- a/parallel_hashmap/phmap.h +++ b/parallel_hashmap/phmap.h @@ -1154,7 +1154,7 @@ public: raw_hash_set(const raw_hash_set& that, const allocator_type& a) : raw_hash_set(0, that.hash_ref(), that.eq_ref(), a) { - reserve(that.capacity()); + rehash(that.capacity()); // operator=() should preserve load_factor // Because the table is guaranteed to be empty, we can do something faster // than a full `insert`. for (const auto& v : that) {