initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / containers / Lists / List / List.H
blob02130ce7066844aa6a2ef15f0cac07284bde6be4
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::List
28 Description
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.
34 SourceFiles
35     List.C
36     ListI.H
37     ListIO.C
39 \*---------------------------------------------------------------------------*/
41 #ifndef List_H
42 #define List_H
44 #include "UList.H"
45 #include "autoPtr.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 namespace Foam
52 class Istream;
53 class Ostream;
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 \*---------------------------------------------------------------------------*/
72 template<class T>
73 class List
75     public UList<T>
78 public:
80     // Constructors
82         //- Null constructor.
83         inline List();
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&);
91         //- Copy constructor.
92         List(const List<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>
102         template<label 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.
118         List(Istream&);
120         //- Clone
121         inline autoPtr<List<T> > clone() const;
124     // Destructor
126         ~List();
129     // Related types
131         //- Declare type of subList
132         typedef SubList<T> subList;
135     // Member functions
137         //- Return a null List
138         static const List<T>& null();
141         // Edit
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.
150             void clear();
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);
160     // Member operators
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&);
181     // Istream operator
183         //- Read List from Istream, discarding contents of existing List.
184         friend Istream& operator>>
185         #ifndef __CINT__
186         <T>
187         #endif
188         (Istream&, List<T>&);
192 template<class T>
193 void sort(List<T>& a);
195 template<class T, class Cmp>
196 void sort(List<T>& a, const Cmp&);
198 template<class T>
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 #   include "ListI.H"
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 #ifdef NoRepository
216 #   include "List.C"
217 #endif
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 #endif
223 // ************************************************************************* //