ENH: HashTable sorted() method
- the sorted() method fills a UPtrList with sorted entries. In some places this can provide a more convenient means of traversing a HashTable in consistent order, without the extra step of creating a sortedToc(). The sorted() method with a UPtrList will also have a lower overhead than creating any sortedToc() or toc() since it is list of pointers and not full copies of the keys. Instead of this: HashTable<someType> table = ...; for (const word& key : table.sortedToc()) { Info<< key << " => " << table[key] << nl; } can write this: for (const auto& iter : table.sorted()) { Info<< iter.key() << " => " << iter.val() << nl; } STYLE: - declare hash entry key 'const' since it is immutable
Showing
- applications/test/HashTable1/Test-HashTable1.C 28 additions, 3 deletionsapplications/test/HashTable1/Test-HashTable1.C
- applications/test/ITstream/Test-ITstream.C 1 addition, 1 deletionapplications/test/ITstream/Test-ITstream.C
- src/OpenFOAM/containers/HashTables/HashTable/HashTable.C 43 additions, 3 deletionssrc/OpenFOAM/containers/HashTables/HashTable/HashTable.C
- src/OpenFOAM/containers/HashTables/HashTable/HashTable.H 89 additions, 52 deletionssrc/OpenFOAM/containers/HashTables/HashTable/HashTable.H
- src/OpenFOAM/containers/HashTables/HashTable/HashTableDetail.H 57 additions, 23 deletions...penFOAM/containers/HashTables/HashTable/HashTableDetail.H
Please register or sign in to comment