From 1dc3236825ccd7d4b7dcf97e290ba8dd1b7d2f98 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Tue, 2 May 2017 12:31:52 +0200
Subject: [PATCH] BUG: fixed odd sizing for hash tables (fixes #460)

---
 src/OpenFOAM/containers/HashTables/HashSet/HashSet.C     | 8 ++++----
 src/OpenFOAM/containers/HashTables/HashTable/HashTable.C | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C
index fb33e0e2c7d..5c1b5798299 100644
--- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C
+++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C
@@ -120,7 +120,7 @@ Foam::HashSet<Key, Hash>::HashSet
     const HashTable<AnyType, Key, AnyHash>& tbl
 )
 :
-    HashTable<nil, Key, Hash>(tbl.size())
+    HashTable<nil, Key, Hash>(tbl.capacity())
 {
     using other_iter =
         typename HashTable<AnyType, Key, AnyHash>::const_iterator;
@@ -159,7 +159,7 @@ Foam::label Foam::HashSet<Key, Hash>::insert(std::initializer_list<Key> lst)
 template<class Key, class Hash>
 void Foam::HashSet<Key, Hash>::operator=(const UList<Key>& lst)
 {
-    assignMultiple(lst.begin(), lst.end(), lst.size());
+    assignMultiple(lst.begin(), lst.end(), 2*lst.size());
 }
 
 
@@ -167,14 +167,14 @@ template<class Key, class Hash>
 template<unsigned Size>
 void Foam::HashSet<Key, Hash>::operator=(const FixedList<Key, Size>& lst)
 {
-    assignMultiple(lst.begin(), lst.end(), lst.size());
+    assignMultiple(lst.begin(), lst.end(), 2*lst.size());
 }
 
 
 template<class Key, class Hash>
 void Foam::HashSet<Key, Hash>::operator=(std::initializer_list<Key> lst)
 {
-    assignMultiple(lst.begin(), lst.end(), lst.size());
+    assignMultiple(lst.begin(), lst.end(), 2*lst.size());
 }
 
 
diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C
index 5e559cf058a..db3256bcb1c 100644
--- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C
+++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C
@@ -115,7 +115,7 @@ Foam::HashTable<T, Key, Hash>::HashTable
     std::initializer_list<Tuple2<Key, T>> lst
 )
 :
-    HashTable<T, Key, Hash>(lst.size())
+    HashTable<T, Key, Hash>(2*lst.size())
 {
     for (const Tuple2<Key, T>& pair : lst)
     {
@@ -638,7 +638,7 @@ void Foam::HashTable<T, Key, Hash>::operator=
     // Could be zero-sized from a previous transfer()
     if (!tableSize_)
     {
-        resize(lst.size());
+        resize(2*lst.size());
     }
     else
     {
-- 
GitLab