diff --git a/applications/test/DLList/Test-DLList.C b/applications/test/DLList/Test-DLList.C index 8e653c4b20..268c8b3ed1 100644 --- a/applications/test/DLList/Test-DLList.C +++ b/applications/test/DLList/Test-DLList.C @@ -56,7 +56,6 @@ int main(int argc, char *argv[]) Info<< "element:" << *iter << endl; } - Info<< nl << "And again using the same STL iterator: " << nl << endl; forAllIters(myList, iter) diff --git a/applications/test/HashPtrTable/Test-hashPtrTable.C b/applications/test/HashPtrTable/Test-hashPtrTable.C index 5133d784b1..e62d596869 100644 --- a/applications/test/HashPtrTable/Test-hashPtrTable.C +++ b/applications/test/HashPtrTable/Test-hashPtrTable.C @@ -36,14 +36,9 @@ void printTable(const HashPtrTable& table) { Info<< table.size() << nl << "(" << nl; - for - ( - typename HashPtrTable::const_iterator iter = table.cbegin(); - iter != table.cend(); - ++iter - ) + forAllConstIters(table, iter) { - const T* ptr = *iter; + const T* ptr = iter.object(); Info<< iter.key() << " = "; if (ptr) { @@ -57,6 +52,22 @@ void printTable(const HashPtrTable& table) } Info<< ")" << endl; + + // Values only, with for-range + Info<< "values ("; + for (auto val : table) + { + Info<< ' '; + if (val) + { + Info<< *val; + } + else + { + Info<< "nullptr"; + } + } + Info<< " )" << nl; } @@ -68,7 +79,9 @@ int main() HashPtrTable myTable; myTable.insert("abc", new double(42.1)); myTable.insert("def", nullptr); - myTable.insert("ghi", new double(3.14159)); + myTable.insert("pi", new double(3.14159)); + myTable.insert("natlog", new double(2.718282)); + myTable.insert("sqrt2", new double(1.414214)); // Info<< myTable << endl; printTable(myTable); @@ -79,8 +92,20 @@ int main() printTable(copy); Info<< copy << endl; + Info<<"\nerase some existing and non-existing entries" << nl; + + auto iter = myTable.find("pi"); + myTable.erase(iter); + + iter = myTable.find("unknownKey"); + myTable.erase(iter); + + myTable.erase("abc"); + myTable.erase("unknownKey"); + + printTable(myTable); + return 0; } - // ************************************************************************* // diff --git a/applications/test/HashSet/Test-hashSet.C b/applications/test/HashSet/Test-hashSet.C index 0b219f2e3d..55640829fb 100644 --- a/applications/test/HashSet/Test-hashSet.C +++ b/applications/test/HashSet/Test-hashSet.C @@ -197,8 +197,12 @@ int main(int argc, char *argv[]) Info<< "setD has no 11" << endl; } + Info<< "setB : " << flatOutput(setB) << endl; Info<< "setD : " << flatOutput(setD) << endl; + setD -= setB; + Info<< "setD -= setB : " << flatOutput(setD) << endl; + // This should not work (yet?) // setD[12] = true; diff --git a/applications/test/HashTable/Test-hashTable.C b/applications/test/HashTable/Test-hashTable.C index 31bff05b0f..8352a88ae0 100644 --- a/applications/test/HashTable/Test-hashTable.C +++ b/applications/test/HashTable/Test-hashTable.C @@ -25,6 +25,9 @@ License #include "HashTable.H" #include "List.H" +#include "SortableList.H" +#include "DynamicList.H" +#include "FlatOutput.H" #include "IOstreams.H" #include "IStringStream.H" #include "OStringStream.H" @@ -163,15 +166,15 @@ int main() << "\ntable2" << table2 << nl; - Info<< "\ntable3" << table3 - << "\nclearStorage table3 ... "; - table3.clearStorage(); - Info<< table3 << nl; + Info<< "\ntable3" << table2 + << "\nclearStorage table2 ... "; + table2.clearStorage(); + Info<< table2 << nl; table1 = { - {"aca", 3.0}, - {"aaw", 6.0}, + {"abc", 3.0}, + {"def", 6.0}, {"acr", 8.0}, {"aec", 10.0} }; @@ -193,7 +196,43 @@ int main() // These do not yet work. Issues resolving the distance. // // List table1vals(table1.begin(), table1.end()); - // wordList table1keys(table1.begin(), table1.end()); + + { + Info<<"distance/size: " + << std::distance(table1.begin(), table1.end()) + << "/" << table1.size() + << " and " + << std::distance(table1.keys().begin(), table1.keys().end()) + << "/" << table1.keys().size() + << nl; + + SortableList sortKeys + // DynamicList sortKeys + ( + table1.keys().begin(), + table1.keys().end() + ); + Info<<"sortKeys: " << flatOutput(sortKeys) << nl; + } + + Info<< "\nFrom table1: " << flatOutput(table1.sortedToc()) << nl + << "retain keys: " << flatOutput(table3.sortedToc()) << nl; + + table1.retain(table3); + Info<< "-> " << flatOutput(table1.sortedToc()) << nl; + + Info<< "Lookup non-existent" << nl; + + Info<< table1.lookup("missing-const", 1.2345e+6) + << " // const-access" << nl; + + Info<< table1("missing-inadvertent", 3.14159) + << " // (inadvertent?) non-const access" << nl; + + Info<< table1("missing-autovivify") + << " // Known auto-vivification (non-const access)" << nl; + + Info<<"\ntable1: " << table1 << endl; Info<< "\nDone\n"; diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C index 9ab2732c2e..d68bc4d7ba 100644 --- a/applications/test/List/Test-List.C +++ b/applications/test/List/Test-List.C @@ -42,6 +42,7 @@ See also #include "vector.H" #include "labelRange.H" +#include "scalarList.H" #include "ListOps.H" #include "SubList.H" @@ -144,6 +145,18 @@ int main(int argc, char *argv[]) labelList longLabelList = identity(15); + // This does not work: + // scalarList slist = identity(15); + // + // More writing, but does work: + scalarList slist + ( + labelRange::null.begin(), + labelRange::identity(15).end() + ); + + Info<<"scalar identity:" << flatOutput(slist) << endl; + Info<< "labels (contiguous=" << contiguous