ENH: simplify HashSet equality test

- reduce the amount of checking.
  Equivalent logic to what HashTable has.
This commit is contained in:
Mark Olesen
2017-04-11 09:34:51 +02:00
parent 31da01d1ea
commit b56227ee2b

View File

@ -121,16 +121,12 @@ inline bool Foam::HashSet<Key, Hash>::operator[](const Key& key) const
template<class Key, class Hash>
bool Foam::HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& rhs) const
{
// Are all lhs elements in rhs?
for (const_iterator iter = this->cbegin(); iter != this->cend(); ++iter)
// Sizes (number of keys) must match
if (this->size() != rhs.size())
{
if (!rhs.found(iter.key()))
{
return false;
}
return false;
}
// Are all rhs elements in lhs?
for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
{
if (!this->found(iter.key()))