From 23b6ea4b855ca2367c0ad12b32d12da65c8b530f Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 7 Mar 2018 17:50:34 +0100 Subject: [PATCH] ENH: provide iterators for IndirectList, UIndirectList - consistency with other containers. Allows range-for, enables various std algorithms, and can be used with ListOp::create() with an iterator range. --- .../test/IndirectList/Test-IndirectList.C | 7 + .../Lists/IndirectList/IndirectList.H | 39 ++-- .../Lists/IndirectList/IndirectListI.H | 20 +- .../Lists/UIndirectList/UIndirectList.C | 10 +- .../Lists/UIndirectList/UIndirectList.H | 197 +++++++++++++++--- .../Lists/UIndirectList/UIndirectListI.H | 52 ++--- .../Lists/UIndirectList/UIndirectListIO.C | 4 +- 7 files changed, 230 insertions(+), 99 deletions(-) diff --git a/applications/test/IndirectList/Test-IndirectList.C b/applications/test/IndirectList/Test-IndirectList.C index 64ac880e0b..25b95990fb 100644 --- a/applications/test/IndirectList/Test-IndirectList.C +++ b/applications/test/IndirectList/Test-IndirectList.C @@ -41,6 +41,13 @@ void printInfo(const ListType& lst) << "addr: " << flatOutput(lst.addressing()) << nl << "list: " << flatOutput(lst) << nl << endl; + + Info<<"for-range :"; + for (const auto& val : lst) + { + Info<< " " << val; + } + Info<< nl; } diff --git a/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H b/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H index 1422a03674..042c2044d9 100644 --- a/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H +++ b/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H @@ -61,10 +61,10 @@ class IndirectListAddressing // Private Member Functions - //- Disallow default bitwise copy construct + //- Disallow copy construct IndirectListAddressing(const IndirectListAddressing&) = delete; - //- Disallow default bitwise assignment + //- Disallow copy assignment void operator=(const IndirectListAddressing&) = delete; @@ -72,10 +72,10 @@ protected: // Constructors - //- Construct by copying the addressing array + //- Copy construct from addressing array explicit inline IndirectListAddressing(const labelUList& addr); - //- Construct by transferring addressing array + //- Move construct from addressing array explicit inline IndirectListAddressing(List