Skip to content
Snippets Groups Projects
Commit 1dc32368 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

BUG: fixed odd sizing for hash tables (fixes #460)

parent f8c58bdd
Branches
Tags
No related merge requests found
...@@ -120,7 +120,7 @@ Foam::HashSet<Key, Hash>::HashSet ...@@ -120,7 +120,7 @@ Foam::HashSet<Key, Hash>::HashSet
const HashTable<AnyType, Key, AnyHash>& tbl const HashTable<AnyType, Key, AnyHash>& tbl
) )
: :
HashTable<nil, Key, Hash>(tbl.size()) HashTable<nil, Key, Hash>(tbl.capacity())
{ {
using other_iter = using other_iter =
typename HashTable<AnyType, Key, AnyHash>::const_iterator; typename HashTable<AnyType, Key, AnyHash>::const_iterator;
...@@ -159,7 +159,7 @@ Foam::label Foam::HashSet<Key, Hash>::insert(std::initializer_list<Key> lst) ...@@ -159,7 +159,7 @@ Foam::label Foam::HashSet<Key, Hash>::insert(std::initializer_list<Key> lst)
template<class Key, class Hash> template<class Key, class Hash>
void Foam::HashSet<Key, Hash>::operator=(const UList<Key>& lst) 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> ...@@ -167,14 +167,14 @@ template<class Key, class Hash>
template<unsigned Size> template<unsigned Size>
void Foam::HashSet<Key, Hash>::operator=(const FixedList<Key, Size>& lst) 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> template<class Key, class Hash>
void Foam::HashSet<Key, Hash>::operator=(std::initializer_list<Key> lst) 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());
} }
......
...@@ -115,7 +115,7 @@ Foam::HashTable<T, Key, Hash>::HashTable ...@@ -115,7 +115,7 @@ Foam::HashTable<T, Key, Hash>::HashTable
std::initializer_list<Tuple2<Key, T>> lst 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) for (const Tuple2<Key, T>& pair : lst)
{ {
...@@ -638,7 +638,7 @@ void Foam::HashTable<T, Key, Hash>::operator= ...@@ -638,7 +638,7 @@ void Foam::HashTable<T, Key, Hash>::operator=
// Could be zero-sized from a previous transfer() // Could be zero-sized from a previous transfer()
if (!tableSize_) if (!tableSize_)
{ {
resize(lst.size()); resize(2*lst.size());
} }
else else
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment