|
|
|
List.HGo 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-2007 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 Class 00026 List<T> 00027 00028 Description 00029 List<T> is a 1D vector of objects of type T, where the size of the vector 00030 is known and used for subscript bounds checking, etc. Storage is allocated 00031 on free-store during construction. 00032 00033 SourceFiles 00034 List.C 00035 ListI.H 00036 ListIO.C 00037 00038 \*---------------------------------------------------------------------------*/ 00039 00040 #ifndef List_H 00041 #define List_H 00042 00043 #include "UList.H" 00044 #include "autoPtr.H" 00045 00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00047 00048 namespace Foam 00049 { 00050 00051 class Istream; 00052 class Ostream; 00053 00054 // * * * * * * Forward declaration of template friend fuctions * * * * * * * // 00055 00056 template<class T> class List; 00057 00058 template<class T> Istream& operator>>(Istream&, List<T>&); 00059 00060 template<class T, label Size> class FixedList; 00061 template<class T> class PtrList; 00062 template<class T> class SLList; 00063 template<class T> class IndirectList; 00064 template<class T> class BiIndirectList; 00065 00066 00067 /*---------------------------------------------------------------------------*\ 00068 Class List Declaration 00069 \*---------------------------------------------------------------------------*/ 00070 00071 template<class T> 00072 class List 00073 : 00074 public UList<T> 00075 { 00076 00077 public: 00078 00079 // Constructors 00080 00081 //- Null constructor. 00082 inline List(); 00083 00084 //- Construct with given size. 00085 explicit List(const label); 00086 00087 //- Construct with given size and value for all elements. 00088 List(const label, const T&); 00089 00090 //- Copy constructor. 00091 List(const List<T>&); 00092 00093 //- Construct as copy or re-use as specified. 00094 List(List<T>&, bool reUse); 00095 00096 //- Construct given size and start and end iterators. 00097 template<class InputIterator> 00098 List(InputIterator first, InputIterator last); 00099 00100 //- Construct as copy of FixedList<T, Size> 00101 template<label Size> 00102 List(const FixedList<T, Size>&); 00103 00104 //- Construct as copy of PtrList<T> 00105 List(const PtrList<T>&); 00106 00107 //- Construct as copy of SLList<T> 00108 List(const SLList<T>&); 00109 00110 //- Construct as copy of IndirectList<T> 00111 List(const IndirectList<T>&); 00112 00113 //- Construct as copy of BiIndirectList<T> 00114 List(const BiIndirectList<T>&); 00115 00116 //- Construct from Istream. 00117 List(Istream&); 00118 00119 //- Clone 00120 inline autoPtr<List<T> > clone() const; 00121 00122 00123 // Destructor 00124 00125 ~List(); 00126 00127 00128 // Related types 00129 00130 //- Declare type of subList 00131 typedef SubList<T> subList; 00132 00133 00134 // Member functions 00135 00136 //- Return a null List 00137 static List<T>& null(); 00138 00139 00140 // Edit 00141 00142 //- Reset size of List. 00143 void setSize(const label); 00144 00145 //- Reset size of List and value for new elements. 00146 void setSize(const label, const T&); 00147 00148 //- Clear the list, i.e. set size to zero. 00149 void clear(); 00150 00151 //- Transfer the contents of the argument List into this List 00152 // and annull the argument list. 00153 void transfer(List<T>&); 00154 00155 //- Return subscript-checked element of UList. 00156 inline T& newElmt(const label); 00157 00158 00159 // Member operators 00160 00161 //- Assignment from UList operator. Takes linear time. 00162 void operator=(const UList<T>&); 00163 00164 //- Assignment operator. Takes linear time. 00165 void operator=(const List<T>&); 00166 00167 //- Assignment from SLList operator. Takes linear time. 00168 void operator=(const SLList<T>&); 00169 00170 //- Assignment from IndirectList operator. Takes linear time. 00171 void operator=(const IndirectList<T>&); 00172 00173 //- Assignment from BiIndirectList operator. Takes linear time. 00174 void operator=(const BiIndirectList<T>&); 00175 00176 //- Assignment of all entries to the given value 00177 inline void operator=(const T&); 00178 00179 00180 // Istream operator 00181 00182 //- Read List from Istream, discarding contents of existing List. 00183 friend Istream& operator>> <T>(Istream&, List<T>&); 00184 }; 00185 00186 00187 template<class T> 00188 void sort(List<T>& a); 00189 00190 template<class T, class Cmp> 00191 void sort(List<T>& a, const Cmp&); 00192 00193 00194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00195 00196 } // End namespace Foam 00197 00198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00199 00200 # include "ListI.H" 00201 00202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00203 00204 #ifdef NoRepository 00205 # include "List.C" 00206 #endif 00207 00208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00209 00210 #endif 00211 00212 // ************************************************************************* // |