00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 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 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your 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, see <http://www.gnu.org/licenses/>. 00023 00024 \*---------------------------------------------------------------------------*/ 00025 00026 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 00027 00028 template<class T> 00029 inline Foam::List<T>::List() 00030 {} 00031 00032 00033 template<class T> 00034 inline Foam::autoPtr<Foam::List<T> > Foam::List<T>::clone() const 00035 { 00036 return autoPtr<List<T> >(new List<T>(*this)); 00037 } 00038 00039 00040 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 00041 00042 template<class T> 00043 inline const Foam::List<T>& Foam::List<T>::null() 00044 { 00045 return *reinterpret_cast< List<T>* >(0); 00046 } 00047 00048 00049 template<class T> 00050 inline void Foam::List<T>::resize(const label newSize) 00051 { 00052 this->setSize(newSize); 00053 } 00054 00055 00056 template<class T> 00057 inline void Foam::List<T>::resize(const label newSize, const T& a) 00058 { 00059 this->setSize(newSize, a); 00060 } 00061 00062 00063 template<class T> 00064 inline T& Foam::List<T>::newElmt(const label i) 00065 { 00066 if (i >= this->size()) 00067 { 00068 setSize(2*this->size()); 00069 } 00070 00071 return UList<T>::operator[](i); 00072 } 00073 00074 00075 template<class T> 00076 inline void Foam::List<T>::size(const label n) 00077 { 00078 UList<T>::size_ = n; 00079 } 00080 00081 00082 template<class T> 00083 inline Foam::label Foam::List<T>::size() const 00084 { 00085 return UList<T>::size_; 00086 } 00087 00088 00089 template<class T> 00090 inline Foam::Xfer< Foam::List<T> > Foam::List<T>::xfer() 00091 { 00092 return xferMove(*this); 00093 } 00094 00095 00096 template<class T> 00097 inline void Foam::List<T>::append(const UList<T>& lst) 00098 { 00099 if (this == &lst) 00100 { 00101 FatalErrorIn 00102 ( 00103 "List<T>::append(const UList<T>&)" 00104 ) << "attempted appending to self" << abort(FatalError); 00105 } 00106 00107 label nextFree = this->size(); 00108 setSize(nextFree + lst.size()); 00109 00110 forAll(lst, elemI) 00111 { 00112 this->operator[](nextFree++) = lst[elemI]; 00113 } 00114 } 00115 00116 00117 template<class T> 00118 inline void Foam::List<T>::append(const UIndirectList<T>& lst) 00119 { 00120 label nextFree = this->size(); 00121 setSize(nextFree + lst.size()); 00122 00123 forAll(lst, elemI) 00124 { 00125 this->operator[](nextFree++) = lst[elemI]; 00126 } 00127 } 00128 00129 00130 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // 00131 00132 template<class T> 00133 inline void Foam::List<T>::operator=(const T& t) 00134 { 00135 UList<T>::operator=(t); 00136 } 00137 00138 00139 // ************************ vim: set sw=4 sts=4 et: ************************ //