mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improve HashTable iterator access and management
- provide key_iterator/const_key_iterator for all hashes,
reuse directly for HashSet as iterator/const_iterator, respectively.
- additional keys() method for HashTable that returns a wrapped to
a pair of begin/end const_iterators with additional size/empty
information that allows these to be used directly by anything else
expecting things with begin/end/size. Unfortunately does not yet
work with std::distance().
Example,
for (auto& k : labelHashTable.keys())
{
...
}
This commit is contained in:
@ -24,6 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "HashTable.H"
|
||||
#include "List.H"
|
||||
#include "IOstreams.H"
|
||||
#include "IStringStream.H"
|
||||
#include "OStringStream.H"
|
||||
@ -177,12 +178,23 @@ int main()
|
||||
|
||||
Info<< "\ntable1" << table1 << nl;
|
||||
|
||||
Info<< "\nrange-for(table1)" << nl;
|
||||
for (auto const& it : table1)
|
||||
Info<< "\nrange-for(table1) - returns values" << nl;
|
||||
for (const auto& it : table1)
|
||||
{
|
||||
Info<< " " << it << nl;
|
||||
Info<< "val:" << it << nl;
|
||||
}
|
||||
|
||||
Info<< "\nrange-for(table1.keys()) - returns keys" << nl;
|
||||
for (const auto& k : table1.keys())
|
||||
{
|
||||
Info<< "key:" << k << nl;
|
||||
}
|
||||
|
||||
// These do not yet work. Issues resolving the distance.
|
||||
//
|
||||
// List<scalar> table1vals(table1.begin(), table1.end());
|
||||
// wordList table1keys(table1.begin(), table1.end());
|
||||
|
||||
Info<< "\nDone\n";
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user