Commit 37ef335d authored by mark's avatar mark
Browse files

ENH: simplify HashSet equality test

- reduce the amount of checking.
  Equivalent logic to what HashTable has.
parent 5d64f3da
......@@ -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)
if (!rhs.found(iter.key()))
// Sizes (number of keys) must match
if (this->size() != rhs.size())
return false;
// Are all rhs elements in lhs?
for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
if (!this->found(iter.key()))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment