Commit 32a332f5 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: add HashTableOps::values() service function

- extract a list of the HashTable values, optionally sorted.
parent 9160dad6
...@@ -140,6 +140,29 @@ struct plusEqOp ...@@ -140,6 +140,29 @@ struct plusEqOp
} }
}; };
//- List of values from HashTable, optionally sorted.
template<class T, class Key, class Hash>
List<T> values(const HashTable<T, Key, Hash>& tbl, const bool doSort=false)
{
List<T> output(tbl.size());
label i=0;
forAllConstIters(tbl, iter)
{
output[i] = iter.object();
++i;
}
if (doSort)
{
Foam::sort(output);
}
return output;
}
} // End namespace HashTableOps } // End namespace HashTableOps
......
Markdown is supported
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