ENH: 'set' instead of 'insert' std::initializer_list to HashTable

- Duplicate entries are handled by overwriting, which corresponds more
  closely to the notion of assignment
This commit is contained in:
Mark Olesen 2019-11-11 17:07:30 +01:00 committed by Andrew Heather
parent b63a6edb24
commit ea214727a5
2 changed files with 4 additions and 2 deletions

View File

@ -97,7 +97,7 @@ Foam::HashTable<T, Key, Hash>::HashTable
{ {
for (const auto& keyval : list) for (const auto& keyval : list)
{ {
insert(keyval.first, keyval.second); set(keyval.first, keyval.second);
} }
} }
@ -809,7 +809,7 @@ void Foam::HashTable<T, Key, Hash>::operator=
for (const auto& keyval : rhs) for (const auto& keyval : rhs)
{ {
insert(keyval.first, keyval.second); set(keyval.first, keyval.second);
} }
} }

View File

@ -222,6 +222,7 @@ public:
HashTable(this_type&& rhs); HashTable(this_type&& rhs);
//- Construct from an initializer list //- Construct from an initializer list
// Duplicate entries are handled by overwriting
HashTable(std::initializer_list<std::pair<Key, T>> list); HashTable(std::initializer_list<std::pair<Key, T>> list);
@ -518,6 +519,7 @@ public:
void operator=(const this_type& rhs); void operator=(const this_type& rhs);
//- Copy assign from an initializer list //- Copy assign from an initializer list
// Duplicate entries are handled by overwriting
void operator=(std::initializer_list<std::pair<Key, T>> rhs); void operator=(std::initializer_list<std::pair<Key, T>> rhs);
//- Move assign //- Move assign