diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C index cfd5754d1b..c334f7bbd9 100644 --- a/applications/test/List/Test-List.C +++ b/applications/test/List/Test-List.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -42,8 +42,6 @@ See also #include "vector.H" #include "ListOps.H" -#include - using namespace Foam; diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H index 287f1525da..3cfd0b40aa 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -286,7 +286,7 @@ public: // STL reverse_iterator //- Reverse iterator for reverse traversal of FixedList - typedef T* reverse_iterator; + typedef std::reverse_iterator reverse_iterator; //- Return reverse_iterator to begin reverse traversing the FixedList inline reverse_iterator rbegin(); @@ -298,7 +298,7 @@ public: // STL const_reverse_iterator //- Reverse iterator for reverse traversal of constant FixedList - typedef const T* const_reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; //- Return const_reverse_iterator to begin reverse traversing FixedList inline const_reverse_iterator crbegin() const; diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H index 590cdf6c81..cf5d492800 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -326,12 +326,11 @@ Foam::FixedList::begin() return v_; } - template -inline typename Foam::FixedList::const_iterator -Foam::FixedList::begin() const +inline typename Foam::FixedList::iterator +Foam::FixedList::end() { - return v_; + return &v_[Size]; } @@ -344,13 +343,21 @@ Foam::FixedList::cbegin() const template -inline typename Foam::FixedList::iterator -Foam::FixedList::end() +inline typename Foam::FixedList::const_iterator +Foam::FixedList::cend() const { return &v_[Size]; } +template +inline typename Foam::FixedList::const_iterator +Foam::FixedList::begin() const +{ + return v_; +} + + template inline typename Foam::FixedList::const_iterator Foam::FixedList::end() const @@ -360,58 +367,50 @@ Foam::FixedList::end() const template -inline typename Foam::FixedList::const_iterator -Foam::FixedList::cend() const -{ - return &v_[Size]; -} - - -template -inline typename Foam::FixedList::iterator +inline typename Foam::FixedList::reverse_iterator Foam::FixedList::rbegin() { - return &v_[Size-1]; + return reverse_iterator(end()); } template -inline typename Foam::FixedList::const_iterator -Foam::FixedList::rbegin() const -{ - return &v_[Size-1]; -} - - -template -inline typename Foam::FixedList::const_iterator -Foam::FixedList::crbegin() const -{ - return &v_[Size-1]; -} - - -template -inline typename Foam::FixedList::iterator +inline typename Foam::FixedList::reverse_iterator Foam::FixedList::rend() { - return &v_[-1]; + return reverse_iterator(begin()); } template -inline typename Foam::FixedList::const_iterator -Foam::FixedList::rend() const +inline typename Foam::FixedList::const_reverse_iterator +Foam::FixedList::crbegin() const { - return &v_[-1]; + return const_reverse_iterator(cend()); } template -inline typename Foam::FixedList::const_iterator +inline typename Foam::FixedList::const_reverse_iterator Foam::FixedList::crend() const { - return &v_[-1]; + return const_reverse_iterator(cbegin()); +} + + +template +inline typename Foam::FixedList::const_reverse_iterator +Foam::FixedList::rbegin() const +{ + return const_reverse_iterator(cend()); +} + + +template +inline typename Foam::FixedList::const_reverse_iterator +Foam::FixedList::rend() const +{ + return const_reverse_iterator(cbegin()); } diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index 3560aa6360..4074e7c1b1 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -297,7 +297,7 @@ public: // STL reverse_iterator //- Reverse iterator for reverse traversal of UList - typedef T* reverse_iterator; + typedef std::reverse_iterator reverse_iterator; //- Return reverse_iterator to begin reverse traversing the UList inline reverse_iterator rbegin(); @@ -309,7 +309,7 @@ public: // STL const_reverse_iterator //- Reverse iterator for reverse traversal of constant UList - typedef const T* const_reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; //- Return const_reverse_iterator to begin reverse traversing the UList inline const_reverse_iterator crbegin() const; diff --git a/src/OpenFOAM/containers/Lists/UList/UListI.H b/src/OpenFOAM/containers/Lists/UList/UListI.H index d7fa231043..3bb3d25687 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListI.H +++ b/src/OpenFOAM/containers/Lists/UList/UListI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -218,19 +218,6 @@ Foam::UList::begin() return v_; } -template -inline typename Foam::UList::const_iterator -Foam::UList::begin() const -{ - return v_; -} - -template -inline typename Foam::UList::const_iterator -Foam::UList::cbegin() const -{ - return v_; -} template inline typename Foam::UList::iterator @@ -239,13 +226,15 @@ Foam::UList::end() return &v_[size_]; } + template inline typename Foam::UList::const_iterator -Foam::UList::end() const +Foam::UList::cbegin() const { - return &v_[size_]; + return v_; } + template inline typename Foam::UList::const_iterator Foam::UList::cend() const @@ -253,48 +242,71 @@ Foam::UList::cend() const return &v_[size_]; } + template -inline typename Foam::UList::iterator +inline typename Foam::UList::const_iterator +Foam::UList::begin() const +{ + return v_; +} + + +template +inline typename Foam::UList::const_iterator +Foam::UList::end() const +{ + return &v_[size_]; +} + + +template +inline typename Foam::UList::reverse_iterator Foam::UList::rbegin() { - return &v_[size_-1]; + return reverse_iterator(end()); } -template -inline typename Foam::UList::const_iterator -Foam::UList::rbegin() const -{ - return &v_[size_-1]; -} template -inline typename Foam::UList::const_iterator -Foam::UList::crbegin() const -{ - return &v_[size_-1]; -} - -template -inline typename Foam::UList::iterator +inline typename Foam::UList::reverse_iterator Foam::UList::rend() { - return &v_[-1]; + return reverse_iterator(begin()); } + template -inline typename Foam::UList::const_iterator -Foam::UList::rend() const +inline typename Foam::UList::const_reverse_iterator +Foam::UList::crbegin() const { - return &v_[-1]; + return const_reverse_iterator(cend()); } + template -inline typename Foam::UList::const_iterator +inline typename Foam::UList::const_reverse_iterator Foam::UList::crend() const { - return &v_[-1]; + return const_reverse_iterator(cbegin()); } + +template +inline typename Foam::UList::const_reverse_iterator +Foam::UList::rbegin() const +{ + return const_reverse_iterator(cend()); +} + + +template +inline typename Foam::UList::const_reverse_iterator +Foam::UList::rend() const +{ + return const_reverse_iterator(cbegin()); +} + + template inline Foam::label Foam::UList::size() const {