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:
Mark Olesen
2017-05-04 10:17:18 +02:00
parent 759306a3e2
commit 03d180724b
16 changed files with 711 additions and 312 deletions

View File

@ -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;