diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C index f2fbd29724d82361795fe2811d71f41f739109ba..2ecdb5c1f050cded907258647b2f83a78401539b 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -218,17 +218,16 @@ void Foam::CompactListList<T, Container>::swap template<class T, class Container> void Foam::CompactListList<T, Container>::transfer ( - CompactListList<T, Container>& lst + CompactListList<T, Container>& list ) { - if (this == &lst) + if (this == &list) { return; // Self-assignment is a no-op } - size_ = lst.size_; - offsets_.transfer(lst.offsets_); - m_.transfer(lst.m_); + this->clear(); + this->swap(list); } diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H index 419f3e7606a5bbf8ed7f778220a31796eaee0d7b..11a07126181a87b6041c80df76e8ff26ce574546 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,7 +59,7 @@ SourceFiles namespace Foam { -// Forward declaration of friend functions and operators +// Forward Declarations template<class T, class Container> class CompactListList; @@ -82,7 +82,7 @@ template<class T, class Container> Ostream& operator<< template<class T, class Container = List<T>> class CompactListList { - // Private data + // Private Data label size_; @@ -100,6 +100,7 @@ public: //- Return a null CompactListList inline static const CompactListList<T, Container>& null(); + // Constructors //- Null constructor. @@ -129,7 +130,7 @@ public: inline CompactListList(CompactListList<T, Container>&& lst); //- Construct as copy or re-use as specified. - inline CompactListList(CompactListList<T, Container>& lst, bool reuse); + inline CompactListList(CompactListList<T, Container>& list, bool reuse); //- Construct from Istream. CompactListList(Istream&); @@ -198,9 +199,8 @@ public: //- Swap contents void swap(CompactListList<T, Container>& lst); - //- Transfer the contents of the argument CompactListList - // into this CompactListList and annul the argument list. - void transfer(CompactListList<T, Container>& lst); + //- Transfer contents into this and annul the argument + void transfer(CompactListList<T, Container>& list); // Other @@ -215,7 +215,7 @@ public: inline label whichColumn(const label row, const label index) const; - // Member operators + // Member Operators //- Return subscript-checked row as UList. inline UList<T> operator[](const label i); @@ -242,7 +242,7 @@ public: inline void operator=(CompactListList<T, Container>&& lst); - // Istream operator + // IO Operators //- Read CompactListList from Istream, discarding contents // of existing CompactListList. diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H b/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H index 1a3c2613abc52765f4e6d54364335b824971164a..a25686235f763f8de0a47a3060f295fee90b516b 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -90,14 +90,19 @@ inline Foam::CompactListList<T, Container>::CompactListList template<class T, class Container> inline Foam::CompactListList<T, Container>::CompactListList ( - CompactListList<T, Container>& lst, + CompactListList<T, Container>& list, bool reuse ) : - size_(lst.size()), - offsets_(lst.offsets_, reuse), - m_(lst.m_, reuse) -{} + size_(list.size()), + offsets_(list.offsets_, reuse), + m_(list.m_, reuse) +{ + if (reuse) + { + list.size_ = 0; + } +} template<class T, class Container>