1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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);
91 // Static data members
94 static const List<T> zero;
97 // Static Member Functions
99 //- Return a null list
100 inline static const List<T>& null();
104 //- Null constructor.
107 //- Construct with given size.
108 explicit List(const label);
110 //- Construct with given size and value for all elements.
111 List(const label, const T&);
113 //- Copy constructor.
114 List(const List<T>&);
116 //- Construct by transferring the parameter contents
117 List(const Xfer< List<T> >&);
119 //- Construct as copy or re-use as specified.
120 List(List<T>&, bool reUse);
122 //- Construct as subset.
123 List(const UList<T>&, const unallocLabelList& mapAddressing);
125 //- Construct given start and end iterators.
126 template<class InputIterator>
127 List(InputIterator first, InputIterator last);
129 //- Construct as copy of FixedList<T, Size>
130 template<unsigned Size>
131 List(const FixedList<T, Size>&);
133 //- Construct as copy of PtrList<T>
134 List(const PtrList<T>&);
136 //- Construct as copy of SLList<T>
137 List(const SLList<T>&);
139 //- Construct as copy of IndirectList<T>
140 List(const IndirectList<T>&);
142 //- Construct as copy of UIndirectList<T>
143 List(const UIndirectList<T>&);
145 //- Construct as copy of BiIndirectList<T>
146 List(const BiIndirectList<T>&);
148 //- Construct from Istream.
152 inline autoPtr<List<T> > clone() const;
162 //- Declare type of subList
163 typedef SubList<T> subList;
168 //- Return the number of elements in the UList.
169 inline label size() const;
174 //- Reset size of List.
175 inline void resize(const label);
177 //- Reset size of List and value for new elements.
178 inline void resize(const label, const T&);
180 //- Reset size of List.
181 void setSize(const label);
183 //- Reset size of List and value for new elements.
184 void setSize(const label, const T&);
186 //- Clear the list, i.e. set size to zero.
189 //- Append a List at the end of this list
190 inline void append(const UList<T>&);
192 //- Append a UIndirectList at the end of this list
193 inline void append(const UIndirectList<T>&);
195 //- Transfer the contents of the argument List into this list
196 // and annull the argument list.
197 void transfer(List<T>&);
199 //- Transfer the contents of the argument List into this list
200 // and annull the argument list.
201 template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
202 void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
204 //- Transfer the contents of the argument List into this list
205 // and annull the argument list.
206 void transfer(SortableList<T>&);
208 //- Transfer contents to the Xfer container
209 inline Xfer< List<T> > xfer();
211 //- Return subscript-checked element of UList.
212 inline T& newElmt(const label);
216 //- Assignment from UList operator. Takes linear time.
217 void operator=(const UList<T>&);
219 //- Assignment operator. Takes linear time.
220 void operator=(const List<T>&);
222 //- Assignment from SLList operator. Takes linear time.
223 void operator=(const SLList<T>&);
225 //- Assignment from IndirectList operator. Takes linear time.
226 void operator=(const IndirectList<T>&);
228 //- Assignment from UIndirectList operator. Takes linear time.
229 void operator=(const UIndirectList<T>&);
231 //- Assignment from BiIndirectList operator. Takes linear time.
232 void operator=(const BiIndirectList<T>&);
234 //- Assignment of all entries to the given value
235 inline void operator=(const T&);
241 //- Read List from Istream, discarding contents of existing List.
242 friend Istream& operator>> <T>(Istream&, List<T>&);
247 //- Read a bracket-delimited list, or handle a single value as list of size 1.
250 // wList = readList<word>(IStringStream("(patch1 patch2 patch3)")());
251 // wList = readList<word>(IStringStream("patch0")());
253 // Mostly useful for handling command-line arguments.
255 List<T> readList(Istream&);
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 } // End namespace Foam
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 // ************************************************************************* //