diff --git a/applications/test/DLList/Test-DLList.C b/applications/test/DLList/Test-DLList.C index d370348982..8e653c4b20 100644 --- a/applications/test/DLList/Test-DLList.C +++ b/applications/test/DLList/Test-DLList.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,6 +41,8 @@ int main(int argc, char *argv[]) { DLList myList; + Info<< "DLList" << nl; + for (int i = 0; i<10; i++) { myList.append(1.3*i); @@ -49,9 +51,7 @@ int main(int argc, char *argv[]) myList.append(100.3); myList.append(500.3); - Info<< nl << "And again using STL iterator: " << nl << endl; - - forAllIter(DLList, myList, iter) + forAllConstIters(myList, iter) { Info<< "element:" << *iter << endl; } @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) Info<< nl << "And again using the same STL iterator: " << nl << endl; - forAllIter(DLList, myList, iter) + forAllIters(myList, iter) { Info<< "Removing " << myList.remove(iter) << endl; } @@ -68,13 +68,10 @@ int main(int argc, char *argv[]) myList.append(200.3); myList.append(100.3); - - Info<< nl << "And again using STL const_iterator: " << nl << endl; - - - forAllConstIter(DLList, myList, iter) + Info<< nl << "Using range-based for: " << nl << endl; + for (auto val : myList) { - Info<< "element:" << *iter << endl; + Info<< "element:" << val << endl; } Info<< nl << "Testing swapUp and swapDown: " << endl; @@ -84,9 +81,9 @@ int main(int argc, char *argv[]) myList.swapUp(myList.DLListBase::first()); myList.swapUp(myList.DLListBase::last()); - forAllIter(DLList, myList, iter) + for (auto val : myList) { - Info<< "element:" << *iter << endl; + Info<< "element:" << val << endl; } Info<< nl << "swapDown" << endl; @@ -94,12 +91,11 @@ int main(int argc, char *argv[]) myList.swapDown(myList.DLListBase::first()); myList.swapDown(myList.DLListBase::last()); - forAllIter(DLList, myList, iter) + for (auto val : myList) { - Info<< "element:" << *iter << endl; + Info<< "element:" << val << endl; } - Info<< nl << "Testing transfer: " << nl << nl << "original: " << myList << endl; diff --git a/applications/test/Dictionary/Test-Dictionary.C b/applications/test/Dictionary/Test-Dictionary.C index f48845a36f..251cb2f841 100644 --- a/applications/test/Dictionary/Test-Dictionary.C +++ b/applications/test/Dictionary/Test-Dictionary.C @@ -168,9 +168,24 @@ int main(int argc, char *argv[]) Info<< nl << "scalarDict2: " << endl; forAllConstIter(PtrDictionary, scalarDict2, iter) { + std::cout<< "iter: " << typeid(*iter).name() << '\n'; + Info<< "elem = " << *iter << endl; } + // FIXME: the deduction seems to be different here. + // - returns pointer (as perhaps actually expected) not the + // underlying value. + forAllConstIters(scalarDict2, iter) + { + std::cout<< "iter: " << typeid(*iter).name() << '\n'; + + Info<< "elem = " << *(*iter) << endl; + } + + std::cout<< "iter type: " + << typeid(stdFoam::begin(scalarDict2)).name() << '\n'; + scalarDict.transfer(scalarDict2); diff --git a/applications/test/HashSet/Test-hashSet.C b/applications/test/HashSet/Test-hashSet.C index dcfa0aec7a..0b219f2e3d 100644 --- a/applications/test/HashSet/Test-hashSet.C +++ b/applications/test/HashSet/Test-hashSet.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,8 @@ Description #include "hashedWordList.H" #include "HashSet.H" #include "Map.H" +#include "labelPairHashes.H" +#include "FlatOutput.H" using namespace Foam; @@ -65,6 +67,14 @@ int main(int argc, char *argv[]) tableB.insert("value5", nil()); tableB.insert("value6", nil()); + Info<< "tableA keys: "; tableA.writeKeys(Info) << endl; + + auto keyIterPair = tableA.keys(); + for (const auto& i : keyIterPair) + { + Info<<" keys: " << i << endl; + } + Map