From 84f9fc5c26bf09160791f84545ed7c414893147d Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Wed, 17 Dec 2008 12:31:50 +0100 Subject: [PATCH] LinkedLists/accessTypes get transfer() method --- .../LinkedLists/accessTypes/ILList/ILList.C | 8 ++++++ .../LinkedLists/accessTypes/ILList/ILList.H | 4 +++ .../LinkedLists/accessTypes/LList/LList.C | 8 ++++++ .../LinkedLists/accessTypes/LList/LList.H | 3 ++ .../accessTypes/LPtrList/LPtrList.C | 28 +++++++++---------- .../accessTypes/LPtrList/LPtrList.H | 8 ++++-- 6 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.C index 99f31c94ea4..565cac94938 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.C @@ -124,6 +124,14 @@ void Foam::ILList<LListBase, T>::clear() } +template<class LListBase, class T> +void Foam::ILList<LListBase, T>::transfer(ILList<LListBase, T>& lst) +{ + clear(); + LListBase::transfer(lst); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class LListBase, class T> diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H index 0eace95f67c..401a8b60388 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H @@ -139,6 +139,10 @@ public: //- Clear the contents of the list void clear(); + //- Transfer the contents of the argument into this List + // and annull the argument list. + void transfer(ILList<LListBase, T>&); + // Member operators diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C index c2fdb1b8203..1c93142b416 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C @@ -65,6 +65,14 @@ void Foam::LList<LListBase, T>::clear() } +template<class LListBase, class T> +void Foam::LList<LListBase, T>::transfer(LList<LListBase, T>& lst) +{ + clear(); + LListBase::transfer(lst); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class LListBase, class T> diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H index fdb589d53c7..4c422f7ccb2 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H @@ -200,6 +200,9 @@ public: //- Delete contents of list void clear(); + //- Transfer the contents of the argument into this List + // and annull the argument list. + void transfer(LList<LListBase, T>&); // Member operators diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.C index f958b183ecc..935e68292c0 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.C @@ -26,15 +26,10 @@ License #include "LPtrList.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class LListBase, class T> -LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& lst) +Foam::LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& lst) : LList<LListBase, T*>() { @@ -48,7 +43,7 @@ LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& lst) // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template<class LListBase, class T> -LPtrList<LListBase, T>::~LPtrList() +Foam::LPtrList<LListBase, T>::~LPtrList() { clear(); } @@ -56,9 +51,8 @@ LPtrList<LListBase, T>::~LPtrList() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//- Return and remove head template<class LListBase, class T> -bool LPtrList<LListBase, T>::eraseHead() +bool Foam::LPtrList<LListBase, T>::eraseHead() { T* tPtr; if ((tPtr = this->removeHead())) @@ -74,7 +68,7 @@ bool LPtrList<LListBase, T>::eraseHead() template<class LListBase, class T> -void LPtrList<LListBase, T>::clear() +void Foam::LPtrList<LListBase, T>::clear() { label oldSize = this->size(); for (label i=0; i<oldSize; i++) @@ -86,10 +80,18 @@ void LPtrList<LListBase, T>::clear() } +template<class LListBase, class T> +void Foam::LPtrList<LListBase, T>::transfer(LPtrList<LListBase, T>& lst) +{ + clear(); + LList<LListBase, T*>::transfer(lst); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class LListBase, class T> -void LPtrList<LListBase, T>::operator=(const LPtrList<LListBase, T>& lst) +void Foam::LPtrList<LListBase, T>::operator=(const LPtrList<LListBase, T>& lst) { clear(); @@ -100,10 +102,6 @@ void LPtrList<LListBase, T>::operator=(const LPtrList<LListBase, T>& lst) } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // #include "LPtrListIO.C" diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H index 601d26f8761..fdb59ea27cd 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H @@ -149,12 +149,16 @@ public: // Edit - //- Remove the head element specified from the list and delete it + //- Remove the head element from the list and delete the pointer bool eraseHead(); - //- Remove the specified element from the list and delete it + //- Clear the contents of the list void clear(); + //- Transfer the contents of the argument into this List + // and annull the argument list. + void transfer(LPtrList<LListBase, T>&); + // Member operators -- GitLab