/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class Foam::List Description A 1D array of objects of type \, where the size of the vector is known and used for subscript bounds checking, etc. Storage is allocated on free-store during construction. SourceFiles List.C ListI.H ListIO.C \*---------------------------------------------------------------------------*/ #ifndef List_H #define List_H #include "UList.H" #include "autoPtr.H" #include "Xfer.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { class Istream; class Ostream; // Forward declaration of friend functions and operators template class List; template Istream& operator>>(Istream&, List&); template class FixedList; template class PtrList; template class SLList; template class DynamicList; template class SortableList; template class IndirectList; template class BiIndirectList; /*---------------------------------------------------------------------------*\ Class List Declaration \*---------------------------------------------------------------------------*/ template class List : public UList { protected: //- Override size to be inconsistent with allocated storage. // Use with care. inline void size(const label); public: // Static Member Functions //- Return a null List inline static const List& null(); // Constructors //- Null constructor. inline List(); //- Construct with given size. explicit List(const label); //- Construct with given size and value for all elements. List(const label, const T&); //- Copy constructor. List(const List&); //- Construct by transferring the parameter contents List(const Xfer >&); //- Construct as copy or re-use as specified. List(List&, bool reUse); //- Construct given start and end iterators. template List(InputIterator first, InputIterator last); //- Construct as copy of FixedList template List(const FixedList&); //- Construct as copy of PtrList List(const PtrList&); //- Construct as copy of SLList List(const SLList&); //- Construct as copy of IndirectList List(const IndirectList&); //- Construct as copy of BiIndirectList List(const BiIndirectList&); //- Construct from Istream. List(Istream&); //- Clone inline autoPtr > clone() const; // Destructor ~List(); // Related types //- Declare type of subList typedef SubList subList; // Member Functions //- Return the number of elements in the UList. inline label size() const; // Edit //- Reset size of List. inline void resize(const label); //- Reset size of List and value for new elements. inline void resize(const label, const T&); //- Reset size of List. void setSize(const label); //- Reset size of List and value for new elements. void setSize(const label, const T&); //- Clear the list, i.e. set size to zero. void clear(); //- Transfer the contents of the argument List into this List // and annull the argument list. void transfer(List&); //- Transfer the contents of the argument List into this List // and annull the argument list. template void transfer(DynamicList&); //- Transfer the contents of the argument List into this List // and annull the argument list. void transfer(SortableList&); //- Transfer contents to the Xfer container inline Xfer > xfer(); //- Return subscript-checked element of UList. inline T& newElmt(const label); // Member operators //- Assignment from UList operator. Takes linear time. void operator=(const UList&); //- Assignment operator. Takes linear time. void operator=(const List&); //- Assignment from SLList operator. Takes linear time. void operator=(const SLList&); //- Assignment from IndirectList operator. Takes linear time. void operator=(const IndirectList&); //- Assignment from BiIndirectList operator. Takes linear time. void operator=(const BiIndirectList&); //- Assignment of all entries to the given value inline void operator=(const T&); // Istream operator //- Read List from Istream, discarding contents of existing List. friend Istream& operator>> #ifndef __CINT__ #endif (Istream&, List&); }; template void sort(List& a); template void sort(List& a, const Cmp&); template void stableSort(List& a); template void stableSort(List& a, const Cmp&); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // # include "ListI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository # include "List.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* //