... | ... | @@ -50,13 +50,29 @@ forAllConstIter(labelHashSet, ids, iter) |
|
|
```
|
|
|
|
|
|
|
|
|
### HashTable/Map/IOobjectList/objectRegistry sorted()
|
|
|
|
|
|
\since 2206
|
|
|
|
|
|
The `sorted()` method provides a _leaner_ and more convenient means of
|
|
|
traversing hashed contents in consistent order than using a
|
|
|
`sortedToc()`:
|
|
|
```
|
|
|
HashTable<Type> myHash ...;
|
|
|
|
|
|
for (const auto& iter : myHash.sorted())
|
|
|
{
|
|
|
os << iter.key() << " = " << iter.val() << nl;
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### HashSet/HashTable/Map toc()
|
|
|
|
|
|
\since 1706
|
|
|
|
|
|
Use a _range-for_ when using `toc()` or `sortedToc()` to access hashes.
|
|
|
It avoids an intermediate variable, and C++ will only need to create the
|
|
|
end-iterator once.
|
|
|
It avoids an intermediate variable, and the compiler will only need to create
|
|
|
the end-iterator once.
|
|
|
|
|
|
```
|
|
|
HashTable<Type> myHash ...;
|
... | ... | @@ -124,6 +140,8 @@ else |
|
|
|
|
|
Some reports of _"HashTable is completely broken"_ can be related to
|
|
|
incorrect use of `HashTable` and misunderstanding its hashing function.
|
|
|
(_After OpenFOAM-v2106 some of the information in this note is out of
|
|
|
date_).
|
|
|
Examining its template signature:
|
|
|
```
|
|
|
template<class T, class Key=word, class Hash=string::hash>
|
... | ... | |