initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / containers / Lists / List / ListI.H
blob58e5576f303b0d625f7b98a25c7865a2bce8e922
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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  * * * * * * * * * * * * * * //
29 template<class T>
30 inline Foam::List<T>::List()
34 template<class T>
35 inline Foam::autoPtr<Foam::List<T> > Foam::List<T>::clone() const
37     return autoPtr<List<T> >(new List<T>(*this));
41 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
43 template<class T>
44 inline const Foam::List<T>& Foam::List<T>::null()
46     return *reinterpret_cast< List<T>* >(0);
50 template<class T>
51 inline void Foam::List<T>::resize(const label newSize)
53     this->setSize(newSize);
57 template<class T>
58 inline void Foam::List<T>::resize(const label newSize, const T& a)
60     this->setSize(newSize, a);
64 template<class T>
65 inline T& Foam::List<T>::newElmt(const label i)
67     if (i >= this->size())
68     {
69         setSize(2*this->size());
70     }
72     return UList<T>::operator[](i);
76 template<class T>
77 inline void Foam::List<T>::size(const label n)
79     UList<T>::size_ = n;
83 template<class T>
84 inline Foam::label Foam::List<T>::size() const
86     return UList<T>::size_;
90 template<class T>
91 inline Foam::Xfer< Foam::List<T> > Foam::List<T>::xfer()
93     return xferMove(*this);
97 template<class T>
98 inline void Foam::List<T>::append(const UList<T>& lst)
100     if (this == &lst)
101     {
102         FatalErrorIn
103         (
104             "List<T>::append(const UList<T>&)"
105         )   << "attempted appending to self" << abort(FatalError);
106     }
108     label nextFree = this->size();
109     setSize(nextFree + lst.size());
111     forAll(lst, elemI)
112     {
113         this->operator[](nextFree++) = lst[elemI];
114     }
118 template<class T>
119 inline void Foam::List<T>::append(const UIndirectList<T>& lst)
121     label nextFree = this->size();
122     setSize(nextFree + lst.size());
124     forAll(lst, elemI)
125     {
126         this->operator[](nextFree++) = lst[elemI];
127     }
131 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
133 template<class T>
134 inline void Foam::List<T>::operator=(const T& t)
136     UList<T>::operator=(t);
140 // ************************************************************************* //