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
29 A 1D array of objects of type \<T\>, where the size of the vector
30 is known and used for subscript bounds checking, etc.
32 Storage is allocated on free-store during construction.
39 \*---------------------------------------------------------------------------*/
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 // Forward declaration of friend functions and operators
58 template<class T> class List;
60 template<class T> Istream& operator>>(Istream&, List<T>&);
62 template<class T, unsigned Size> class FixedList;
63 template<class T> class PtrList;
64 template<class T> class SLList;
65 template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
67 template<class T> class SortableList;
68 template<class T> class IndirectList;
69 template<class T> class UIndirectList;
70 template<class T> class BiIndirectList;
72 typedef UList<label> unallocLabelList;
74 /*---------------------------------------------------------------------------*\
75 Class List Declaration
76 \*---------------------------------------------------------------------------*/
86 //- Override size to be inconsistent with allocated storage.
88 inline void size(const label);
92 // Static Member Functions
94 //- Return a null List
95 inline static const List<T>& null();
102 //- Construct with given size.
103 explicit List(const label);
105 //- Construct with given size and value for all elements.
106 List(const label, const T&);
108 //- Copy constructor.
109 List(const List<T>&);
111 //- Construct by transferring the parameter contents
112 List(const Xfer< List<T> >&);
114 //- Construct as copy or re-use as specified.
115 List(List<T>&, bool reUse);
117 //- Construct as subset.
118 List(const UList<T>&, const unallocLabelList& mapAddressing);
120 //- Construct given start and end iterators.
121 template<class InputIterator>
122 List(InputIterator first, InputIterator last);
124 //- Construct as copy of FixedList<T, Size>
125 template<unsigned Size>
126 List(const FixedList<T, Size>&);
128 //- Construct as copy of PtrList<T>
129 List(const PtrList<T>&);
131 //- Construct as copy of SLList<T>
132 List(const SLList<T>&);
134 //- Construct as copy of IndirectList<T>
135 List(const IndirectList<T>&);
137 //- Construct as copy of UIndirectList<T>
138 List(const UIndirectList<T>&);
140 //- Construct as copy of BiIndirectList<T>
141 List(const BiIndirectList<T>&);
143 //- Construct from Istream.
147 inline autoPtr<List<T> > clone() const;
157 //- Declare type of subList
158 typedef SubList<T> subList;
163 //- Return the number of elements in the UList.
164 inline label size() const;
169 //- Reset size of List.
170 inline void resize(const label);
172 //- Reset size of List and value for new elements.
173 inline void resize(const label, const T&);
175 //- Reset size of List.
176 void setSize(const label);
178 //- Reset size of List and value for new elements.
179 void setSize(const label, const T&);
181 //- Clear the list, i.e. set size to zero.
184 //- Append a List at the end of this list
185 inline void append(const UList<T>&);
187 //- Append a UIndirectList at the end of this list
188 inline void append(const UIndirectList<T>&);
190 //- Transfer the contents of the argument List into this list
191 // and annull the argument list.
192 void transfer(List<T>&);
194 //- Transfer the contents of the argument List into this list
195 // and annull the argument list.
196 template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
197 void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
199 //- Transfer the contents of the argument List into this list
200 // and annull the argument list.
201 void transfer(SortableList<T>&);
203 //- Transfer contents to the Xfer container
204 inline Xfer< List<T> > xfer();
206 //- Return subscript-checked element of UList.
207 inline T& newElmt(const label);
211 //- Assignment from UList operator. Takes linear time.
212 void operator=(const UList<T>&);
214 //- Assignment operator. Takes linear time.
215 void operator=(const List<T>&);
217 //- Assignment from SLList operator. Takes linear time.
218 void operator=(const SLList<T>&);
220 //- Assignment from IndirectList operator. Takes linear time.
221 void operator=(const IndirectList<T>&);
223 //- Assignment from UIndirectList operator. Takes linear time.
224 void operator=(const UIndirectList<T>&);
226 //- Assignment from BiIndirectList operator. Takes linear time.
227 void operator=(const BiIndirectList<T>&);
229 //- Assignment of all entries to the given value
230 inline void operator=(const T&);
236 //- Read List from Istream, discarding contents of existing List.
237 friend Istream& operator>> <T>(Istream&, List<T>&);
242 //- Read a bracket-delimited list, or handle a single value as list of size 1.
245 // wList = readList<word>(IStringStream("(patch1 patch2 patch3)")());
246 // wList = readList<word>(IStringStream("patch0")());
248 // Mostly useful for handling command-line arguments.
250 List<T> readList(Istream&);
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 } // End namespace Foam
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 // ************************************************************************* //