OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

ListI.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00028 
00029 template<class T>
00030 inline Foam::List<T>::List()
00031 {}
00032 
00033 
00034 template<class T>
00035 inline Foam::autoPtr<Foam::List<T> > Foam::List<T>::clone() const
00036 {
00037     return autoPtr<List<T> >(new List<T>(*this));
00038 }
00039 
00040 
00041 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00042 
00043 template<class T>
00044 inline const Foam::List<T>& Foam::List<T>::null()
00045 {
00046     return *reinterpret_cast< List<T>* >(0);
00047 }
00048 
00049 
00050 template<class T>
00051 inline void Foam::List<T>::resize(const label newSize)
00052 {
00053     this->setSize(newSize);
00054 }
00055 
00056 
00057 template<class T>
00058 inline void Foam::List<T>::resize(const label newSize, const T& a)
00059 {
00060     this->setSize(newSize, a);
00061 }
00062 
00063 
00064 template<class T>
00065 inline T& Foam::List<T>::newElmt(const label i)
00066 {
00067     if (i >= this->size())
00068     {
00069         setSize(2*this->size());
00070     }
00071 
00072     return UList<T>::operator[](i);
00073 }
00074 
00075 
00076 template<class T>
00077 inline void Foam::List<T>::size(const label n)
00078 {
00079     UList<T>::size_ = n;
00080 }
00081 
00082 
00083 template<class T>
00084 inline Foam::label Foam::List<T>::size() const
00085 {
00086     return UList<T>::size_;
00087 }
00088 
00089 
00090 template<class T>
00091 inline Foam::Xfer< Foam::List<T> > Foam::List<T>::xfer()
00092 {
00093     return xferMove(*this);
00094 }
00095 
00096 
00097 template<class T>
00098 inline void Foam::List<T>::append(const UList<T>& lst)
00099 {
00100     if (this == &lst)
00101     {
00102         FatalErrorIn
00103         (
00104             "List<T>::append(const UList<T>&)"
00105         )   << "attempted appending to self" << abort(FatalError);
00106     }
00107 
00108     label nextFree = this->size();
00109     setSize(nextFree + lst.size());
00110 
00111     forAll(lst, elemI)
00112     {
00113         this->operator[](nextFree++) = lst[elemI];
00114     }
00115 }
00116 
00117 
00118 template<class T>
00119 inline void Foam::List<T>::append(const UIndirectList<T>& lst)
00120 {
00121     label nextFree = this->size();
00122     setSize(nextFree + lst.size());
00123 
00124     forAll(lst, elemI)
00125     {
00126         this->operator[](nextFree++) = lst[elemI];
00127     }
00128 }
00129 
00130 
00131 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00132 
00133 template<class T>
00134 inline void Foam::List<T>::operator=(const T& t)
00135 {
00136     UList<T>::operator=(t);
00137 }
00138 
00139 
00140 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd