1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 inline Foam::List<T>::List()
35 inline Foam::autoPtr<Foam::List<T> > Foam::List<T>::clone() const
37 return autoPtr<List<T> >(new List<T>(*this));
41 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
44 inline const Foam::List<T>& Foam::List<T>::null()
46 return *reinterpret_cast< List<T>* >(0);
51 inline void Foam::List<T>::resize(const label newSize)
53 this->setSize(newSize);
58 inline void Foam::List<T>::resize(const label newSize, const T& a)
60 this->setSize(newSize, a);
65 inline T& Foam::List<T>::newElmt(const label i)
67 if (i >= this->size())
69 setSize(2*this->size());
72 return UList<T>::operator[](i);
77 inline void Foam::List<T>::size(const label n)
84 inline Foam::label Foam::List<T>::size() const
86 return UList<T>::size_;
91 inline Foam::Xfer< Foam::List<T> > Foam::List<T>::xfer()
93 return xferMove(*this);
98 inline void Foam::List<T>::append(const UList<T>& lst)
104 "List<T>::append(const UList<T>&)"
105 ) << "attempted appending to self" << abort(FatalError);
108 label nextFree = this->size();
109 setSize(nextFree + lst.size());
113 this->operator[](nextFree++) = lst[elemI];
119 inline void Foam::List<T>::append(const UIndirectList<T>& lst)
121 label nextFree = this->size();
122 setSize(nextFree + lst.size());
126 this->operator[](nextFree++) = lst[elemI];
131 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
134 inline void Foam::List<T>::operator=(const T& t)
136 UList<T>::operator=(t);
140 // ************************************************************************* //