ENH: PtrList: append function

This commit is contained in:
mattijs
2013-06-14 12:47:30 +01:00
parent d97a966aa1
commit 9991ac08bb
2 changed files with 32 additions and 1 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -189,6 +189,11 @@ public:
// allocated entries.
void clear();
//- Append an element at the end of the list
inline void append(const T*);
inline void append(const autoPtr<T>&);
inline void append(const tmp<T>&);
//- Transfer the contents of the argument PtrList into this PtrList
// and annul the argument list.
void transfer(PtrList<T>&);

View File

@ -79,6 +79,32 @@ inline void Foam::PtrList<T>::resize(const label newSize)
}
template<class T>
inline void Foam::PtrList<T>::append(const T* ptr)
{
label sz = size();
this->setSize(sz+1);
ptrs_[sz] = ptr;
}
template<class T>
inline void Foam::PtrList<T>::append(const autoPtr<T>& aptr)
{
return append(const_cast<autoPtr<T>&>(aptr).ptr());
}
template<class T>
inline void Foam::PtrList<T>::append
(
const tmp<T>& t
)
{
return append(const_cast<tmp<T>&>(t).ptr());
}
template<class T>
inline bool Foam::PtrList<T>::set(const label i) const
{