FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

BiIndirectList.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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::BiIndirectList
00026 
00027 Description
00028     Indexes into negList (negative index) or posList (zero or positive index).
00029 
00030 SourceFiles
00031     BiIndirectListI.H
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef BiIndirectList_H
00036 #define BiIndirectList_H
00037 
00038 #include <OpenFOAM/List.H>
00039 
00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00041 
00042 namespace Foam
00043 {
00044 
00045 /*---------------------------------------------------------------------------*\
00046                            Class BiIndirectList Declaration
00047 \*---------------------------------------------------------------------------*/
00048 
00049 template<class T>
00050 class BiIndirectList
00051 {
00052     // Private data
00053 
00054         UList<T>& posList_;
00055         UList<T>& negList_;
00056         List<label> addressing_;
00057 
00058 
00059 public:
00060 
00061     // Constructors
00062 
00063         //- Construct given the complete lists and the addressing array
00064         inline BiIndirectList
00065         (
00066             const UList<T>& posList,
00067             const UList<T>& negList,
00068             const UList<label>&
00069         );
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>& posList() const;
00080             inline const UList<T>& negList() const;
00081             inline const List<label>& addressing() const;
00082             inline List<label>& addressing();
00083 
00084             //- Calculate index given whether index is into posList or negList
00085             inline static label posIndex(const label);
00086             inline static label negIndex(const label);
00087 
00088 
00089         // Member Operators
00090 
00091             //- Return the addressed elements as a List
00092             inline List<T> operator()() const;
00093 
00094             //- Return non-const access to an element
00095             inline T& operator[](const label);
00096 
00097             //- Return const access to an element
00098             inline const T& operator[](const label) const;
00099 
00100             //- Assignment from UList of addressed elements
00101             inline void operator=(const UList<T>&);
00102 
00103             //- Assignment of all entries to the given value
00104             inline void operator=(const T&);
00105 };
00106 
00107 
00108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00109 
00110 } // End namespace Foam
00111 
00112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00113 
00114 #include <OpenFOAM/BiIndirectListI.H>
00115 
00116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00117 
00118 #endif
00119 
00120 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines