mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add HashTableOps::values() service function
- extract a list of the HashTable values, optionally sorted.
This commit is contained in:
@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user