mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: expose HashTable iterator object() methods
- to the referenced object via a method name, which may be clearer
than deferencing the iterator
[key, value] => iter.key(), *iter
[key, value] => iter.key(), iter()
[key, value] => iter.key(), iter.object()
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -49,6 +49,8 @@ int main()
|
||||
{"aec", 10.0}
|
||||
};
|
||||
|
||||
// Info<< "\ntable1: " << table1<< endl;
|
||||
|
||||
// Erase by key
|
||||
table1.erase("aaw");
|
||||
|
||||
@ -60,7 +62,7 @@ int main()
|
||||
Info<< "\ntable1 sortedToc: " << table1.sortedToc() << endl;
|
||||
table1.printInfo(Info)
|
||||
<< "table1 [" << table1.size() << "] " << endl;
|
||||
forAllIter(HashTable<scalar>, table1, iter)
|
||||
forAllConstIter(HashTable<scalar>, table1, iter)
|
||||
{
|
||||
Info<< iter.key() << " => " << iter() << nl;
|
||||
}
|
||||
@ -106,7 +108,7 @@ int main()
|
||||
Info<< "\nerase table2 by iterator" << nl;
|
||||
forAllIter(HashTable<scalar>, table2, iter)
|
||||
{
|
||||
Info<< "erasing " << iter.key() << " => " << iter() << " ... ";
|
||||
Info<< "erasing " << iter.key() << " => " << iter.object() << " ... ";
|
||||
table2.erase(iter);
|
||||
Info<< "erased" << endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user