OpenFOAM logo
Open Source CFD Toolkit

List.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     List<T>
00027 
00028 Description
00029     List<T> is a 1D vector of objects of type T, where the size of the vector
00030     is known and used for subscript bounds checking, etc.  Storage is allocated
00031     on free-store during construction.
00032 
00033 SourceFiles
00034     List.C
00035     ListI.H
00036     ListIO.C
00037 
00038 \*---------------------------------------------------------------------------*/
00039 
00040 #ifndef List_H
00041 #define List_H
00042 
00043 #include "UList.H"
00044 #include "autoPtr.H"
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 class Istream;
00052 class Ostream;
00053 
00054 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
00055 
00056 template<class T> class List;
00057 
00058 template<class T> Istream& operator>>(Istream&, List<T>&);
00059 
00060 template<class T, label Size> class FixedList;
00061 template<class T> class PtrList;
00062 template<class T> class SLList;
00063 template<class T> class IndirectList;
00064 
00065 
00066 /*---------------------------------------------------------------------------*\
00067                            Class List Declaration
00068 \*---------------------------------------------------------------------------*/
00069 
00070 template<class T>
00071 class List
00072 :
00073     public UList<T>
00074 {
00075 
00076 public:
00077 
00078     // Constructors
00079 
00080         //- Null constructor.
00081         inline List();
00082 
00083         //- Construct with given size.
00084         explicit List(const label);
00085 
00086         //- Construct with given size and value for all elements.
00087         List(const label, const T&);
00088 
00089         //- Copy constructor.
00090         List(const List<T>&);
00091 
00092         //- Construct as copy or re-use as specified.
00093         List(List<T>&, bool reUse);
00094 
00095         //- Construct given size and start and end iterators.
00096         template<class InputIterator>
00097         List(InputIterator first, InputIterator last);
00098 
00099         //- Construct as copy of FixedList<T, Size>
00100         template<label Size>
00101         List(const FixedList<T, Size>&);
00102 
00103         //- Construct as copy of PtrList<T>
00104         List(const PtrList<T>&);
00105 
00106         //- Construct as copy of SLList<T>
00107         List(const SLList<T>&);
00108 
00109         //- Construct as copy of IndirectList<T>
00110         List(const IndirectList<T>&);
00111 
00112         //- Construct from Istream.
00113         List(Istream&);
00114 
00115         //- Clone
00116         inline autoPtr<List<T> > clone() const;
00117 
00118 
00119     // Destructor
00120 
00121         ~List();
00122 
00123 
00124     // Related types
00125 
00126         //- Declare type of subList
00127         typedef SubList<T> subList;
00128 
00129 
00130     // Member functions
00131 
00132         //- Return a null List
00133         static List<T>& null();
00134 
00135 
00136         // Edit
00137 
00138             //- Reset size of List.
00139             void setSize(const label);
00140 
00141             //- Reset size of List and value for new elements.
00142             void setSize(const label, const T&);
00143 
00144             //- Clear the list, i.e. set size to zero.
00145             void clear();
00146 
00147             //- Transfer the contents of the argument List into this List
00148             //  and annull the argument list.
00149             void transfer(List<T>&);
00150 
00151             //- Return subscript-checked element of UList.
00152             inline T& newElmt(const label);
00153 
00154 
00155     // Member operators
00156 
00157         //- Assignment from UList operator. Takes linear time.
00158         void operator=(const UList<T>&);
00159 
00160         //- Assignment operator. Takes linear time.
00161         void operator=(const List<T>&);
00162 
00163         //- Assignment from SLList operator. Takes linear time.
00164         void operator=(const SLList<T>&);
00165 
00166         //- Assignment from IndirectList operator. Takes linear time.
00167         void operator=(const IndirectList<T>&);
00168 
00169         //- Assignment of all entries to the given value
00170         inline void operator=(const T&);
00171 
00172 
00173     // Istream operator
00174 
00175         //- Read List from Istream, discarding contents of existing List.
00176         friend Istream& operator>> <T>(Istream&, List<T>&);
00177 };
00178 
00179 
00180 template<class T>
00181 void sort(List<T>& a);
00182 
00183 template<class T, class Cmp>
00184 void sort(List<T>& a, const Cmp&);
00185 
00186 
00187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00188 
00189 } // End namespace Foam
00190 
00191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00192 
00193 #   include "ListI.H"
00194 
00195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00196 
00197 #ifdef NoRepository
00198 #   include "List.C"
00199 #endif
00200 
00201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00202 
00203 #endif
00204 
00205 // ************************************************************************* //
For further information go to www.openfoam.org