1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
28 A 1D array of objects of type \<T\>, where the size of the vector
29 is known and used for subscript bounds checking, etc.
31 Storage is allocated on free-store during construction.
38 \*---------------------------------------------------------------------------*/
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 // Forward declaration of friend functions and operators
57 template<class T> class List;
59 template<class T> Istream& operator>>(Istream&, List<T>&);
61 template<class T, unsigned Size> class FixedList;
62 template<class T> class PtrList;
63 template<class T> class SLList;
64 template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
66 template<class T> class SortableList;
67 template<class T> class IndirectList;
68 template<class T> class UIndirectList;
69 template<class T> class BiIndirectList;
71 typedef UList<label> unallocLabelList;
73 /*---------------------------------------------------------------------------*\
74 Class List Declaration
75 \*---------------------------------------------------------------------------*/
85 //- Override size to be inconsistent with allocated storage.
87 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 labelUList& 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 explicit List(const FixedList<T, Size>&);
128 //- Construct as copy of PtrList<T>
129 explicit List(const PtrList<T>&);
131 //- Construct as copy of SLList<T>
132 explicit List(const SLList<T>&);
134 //- Construct as copy of UIndirectList<T>
135 explicit List(const UIndirectList<T>&);
137 //- Construct as copy of BiIndirectList<T>
138 explicit List(const BiIndirectList<T>&);
140 //- Construct from Istream.
144 inline autoPtr<List<T> > clone() const;
153 //- Declare type of subList
154 typedef SubList<T> subList;
159 //- Return the number of elements in the UList.
160 inline label size() const;
165 //- Reset size of List.
166 inline void resize(const label);
168 //- Reset size of List and value for new elements.
169 inline void resize(const label, const T&);
171 //- Reset size of List.
172 void setSize(const label);
174 //- Reset size of List and value for new elements.
175 void setSize(const label, const T&);
177 //- Clear the list, i.e. set size to zero.
180 //- Append an element at the end of the list
181 inline void append(const T&);
183 //- Append a List at the end of this list
184 inline void append(const UList<T>&);
186 //- Append a UIndirectList at the end of this list
187 inline void append(const UIndirectList<T>&);
189 //- Transfer the contents of the argument List into this list
190 // and annul the argument list.
191 void transfer(List<T>&);
193 //- Transfer the contents of the argument List into this list
194 // and annul the argument list.
195 template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
196 void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
198 //- Transfer the contents of the argument List into this list
199 // and annul the argument list.
200 void transfer(SortableList<T>&);
202 //- Transfer contents to the Xfer container
203 inline Xfer<List<T> > xfer();
205 //- Return subscript-checked element of UList.
206 inline T& newElmt(const label);
210 //- Assignment from UList operator. Takes linear time.
211 void operator=(const UList<T>&);
213 //- Assignment operator. Takes linear time.
214 void operator=(const List<T>&);
216 //- Assignment from SLList operator. Takes linear time.
217 void operator=(const SLList<T>&);
219 //- Assignment from UIndirectList operator. Takes linear time.
220 void operator=(const UIndirectList<T>&);
222 //- Assignment from BiIndirectList operator. Takes linear time.
223 void operator=(const BiIndirectList<T>&);
225 //- Assignment of all entries to the given value
226 inline void operator=(const T&);
231 //- Read List from Istream, discarding contents of existing List.
232 friend Istream& operator>> <T>
233 (Istream&, List<T>&);
237 //- Read a bracket-delimited list, or handle a single value as list of size 1.
240 // wList = readList<word>(IStringStream("(patch1 patch2 patch3)")());
241 // wList = readList<word>(IStringStream("patch0")());
243 // Mostly useful for handling command-line arguments.
245 List<T> readList(Istream&);
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 } // End namespace Foam
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 // ************************************************************************* //