ENH: add HashTable += operation (combines HashTables)

- adjust return values of HashSet operators.
This commit is contained in:
Mark Olesen
2018-01-23 16:35:43 +01:00
parent 7f3d4b3554
commit 39ee5d5079
6 changed files with 75 additions and 38 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -880,6 +880,32 @@ bool Foam::HashTable<T, Key, Hash>::operator!=
}
template<class T, class Key, class Hash>
Foam::HashTable<T, Key, Hash>& Foam::HashTable<T, Key, Hash>::operator+=
(
const HashTable<T, Key, Hash>& rhs
)
{
// Avoid no-ops:
if (rhs.size() || this != &rhs)
{
if (this->size())
{
for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
{
insert(iter.key(), iter.object());
}
}
else
{
(*this) = rhs;
}
}
return *this;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Iterators, Friend Operators