LinkedLists/accessTypes get transfer() method

This commit is contained in:
Mark Olesen
2008-12-17 12:31:50 +01:00
parent 9681a66a80
commit 84f9fc5c26
6 changed files with 42 additions and 17 deletions

View File

@ -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 * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class LListBase, class T> template<class LListBase, class T>

View File

@ -139,6 +139,10 @@ public:
//- Clear the contents of the list //- Clear the contents of the list
void clear(); void clear();
//- Transfer the contents of the argument into this List
// and annull the argument list.
void transfer(ILList<LListBase, T>&);
// Member operators // Member operators

View File

@ -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 * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class LListBase, class T> template<class LListBase, class T>

View File

@ -200,6 +200,9 @@ public:
//- Delete contents of list //- Delete contents of list
void clear(); void clear();
//- Transfer the contents of the argument into this List
// and annull the argument list.
void transfer(LList<LListBase, T>&);
// Member operators // Member operators

View File

@ -26,15 +26,10 @@ License
#include "LPtrList.H" #include "LPtrList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class LListBase, class T> 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*>() LList<LListBase, T*>()
{ {
@ -48,7 +43,7 @@ LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& lst)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class LListBase, class T> template<class LListBase, class T>
LPtrList<LListBase, T>::~LPtrList() Foam::LPtrList<LListBase, T>::~LPtrList()
{ {
clear(); clear();
} }
@ -56,9 +51,8 @@ LPtrList<LListBase, T>::~LPtrList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return and remove head
template<class LListBase, class T> template<class LListBase, class T>
bool LPtrList<LListBase, T>::eraseHead() bool Foam::LPtrList<LListBase, T>::eraseHead()
{ {
T* tPtr; T* tPtr;
if ((tPtr = this->removeHead())) if ((tPtr = this->removeHead()))
@ -74,7 +68,7 @@ bool LPtrList<LListBase, T>::eraseHead()
template<class LListBase, class T> template<class LListBase, class T>
void LPtrList<LListBase, T>::clear() void Foam::LPtrList<LListBase, T>::clear()
{ {
label oldSize = this->size(); label oldSize = this->size();
for (label i=0; i<oldSize; i++) 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 * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class LListBase, class T> 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(); clear();
@ -100,10 +102,6 @@ void LPtrList<LListBase, T>::operator=(const LPtrList<LListBase, T>& lst)
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
#include "LPtrListIO.C" #include "LPtrListIO.C"

View File

@ -149,12 +149,16 @@ public:
// Edit // 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(); bool eraseHead();
//- Remove the specified element from the list and delete it //- Clear the contents of the list
void clear(); void clear();
//- Transfer the contents of the argument into this List
// and annull the argument list.
void transfer(LPtrList<LListBase, T>&);
// Member operators // Member operators