OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

UIndirectList.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-2009 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     Foam::UIndirectList
00027 
00028 Description
00029     A List with indirect addressing.
00030     Like IndirectList but does not store addressing.
00031 
00032 SourceFiles
00033     UIndirectListI.H
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef UIndirectList_H
00038 #define UIndirectList_H
00039 
00040 #include "List.H"
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 namespace Foam
00045 {
00046 
00047 // Forward declaration of friend functions and operators
00048 template<class T> class UIndirectList;
00049 template<class T> Ostream& operator<<(Ostream&, const UIndirectList<T>&);
00050 
00051 /*---------------------------------------------------------------------------*\
00052                         Class UIndirectList Declaration
00053 \*---------------------------------------------------------------------------*/
00054 
00055 template<class T>
00056 class UIndirectList
00057 {
00058     // Private data
00059 
00060         UList<T>& completeList_;
00061         const UList<label>& addressing_;
00062 
00063 
00064 public:
00065 
00066     // Constructors
00067 
00068         //- Construct given the complete list and the addressing array
00069         inline UIndirectList(const UList<T>&, const UList<label>&);
00070 
00071 
00072     // Member Functions
00073 
00074         // Access
00075 
00076             inline label size() const;
00077             inline bool  empty() const;
00078 
00079             inline const UList<T>& completeList() const;
00080             inline const List<label>& addressing() const;
00081 
00082 
00083         // Member Operators
00084 
00085             //- Return the addressed elements as a List
00086             inline List<T> operator()() const;
00087 
00088             //- Return non-const access to an element
00089             inline T& operator[](const label);
00090 
00091             //- Return const access to an element
00092             inline const T& operator[](const label) const;
00093 
00094             //- Assignment from UList of addressed elements
00095             inline void operator=(const UList<T>&);
00096 
00097             //- Assignment of all entries to the given value
00098             inline void operator=(const T&);
00099 
00100 
00101     // Ostream operator
00102 
00103         //- Write UIndirectList to Ostream
00104         //  Binary output is currently still a bit of a problem
00105         friend Ostream& operator<< <T>
00106         (
00107             Ostream&,
00108             const UIndirectList<T>&
00109         );
00110 };
00111 
00112 
00113 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00114 
00115 } // End namespace Foam
00116 
00117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00118 
00119 #include "UIndirectListI.H"
00120 
00121 #ifdef NoRepository
00122 #   include "UIndirectListIO.C"
00123 #endif
00124 
00125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00126 
00127 #endif
00128 
00129 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd