1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 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 \*---------------------------------------------------------------------------*/
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, label Size> class FixedList;
62 template<class T> class PtrList;
63 template<class T> class SLList;
64 template<class T> class IndirectList;
65 template<class T> class BiIndirectList;
68 /*---------------------------------------------------------------------------*\
69 Class List Declaration
70 \*---------------------------------------------------------------------------*/
85 //- Construct with given size.
86 explicit List(const label);
88 //- Construct with given size and value for all elements.
89 List(const label, const T&);
94 //- Construct as copy or re-use as specified.
95 List(List<T>&, bool reUse);
97 //- Construct given size and start and end iterators.
98 template<class InputIterator>
99 List(InputIterator first, InputIterator last);
101 //- Construct as copy of FixedList<T, Size>
103 List(const FixedList<T, Size>&);
105 //- Construct as copy of PtrList<T>
106 List(const PtrList<T>&);
108 //- Construct as copy of SLList<T>
109 List(const SLList<T>&);
111 //- Construct as copy of IndirectList<T>
112 List(const IndirectList<T>&);
114 //- Construct as copy of BiIndirectList<T>
115 List(const BiIndirectList<T>&);
117 //- Construct from Istream.
121 inline autoPtr<List<T> > clone() const;
131 //- Declare type of subList
132 typedef SubList<T> subList;
137 //- Return a null List
138 static const List<T>& null();
143 //- Reset size of List.
144 void setSize(const label);
146 //- Reset size of List and value for new elements.
147 void setSize(const label, const T&);
149 //- Clear the list, i.e. set size to zero.
152 //- Transfer the contents of the argument List into this List
153 // and annull the argument list.
154 void transfer(List<T>&);
156 //- Return subscript-checked element of UList.
157 inline T& newElmt(const label);
162 //- Assignment from UList operator. Takes linear time.
163 void operator=(const UList<T>&);
165 //- Assignment operator. Takes linear time.
166 void operator=(const List<T>&);
168 //- Assignment from SLList operator. Takes linear time.
169 void operator=(const SLList<T>&);
171 //- Assignment from IndirectList operator. Takes linear time.
172 void operator=(const IndirectList<T>&);
174 //- Assignment from BiIndirectList operator. Takes linear time.
175 void operator=(const BiIndirectList<T>&);
177 //- Assignment of all entries to the given value
178 inline void operator=(const T&);
183 //- Read List from Istream, discarding contents of existing List.
184 friend Istream& operator>>
188 (Istream&, List<T>&);
193 void sort(List<T>& a);
195 template<class T, class Cmp>
196 void sort(List<T>& a, const Cmp&);
199 void stableSort(List<T>& a);
201 template<class T, class Cmp>
202 void stableSort(List<T>& a, const Cmp&);
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 } // End namespace Foam
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 // ************************************************************************* //