OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

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-2007 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     BiIndirectList
00027 
00028 Description
00029     Indexes into left list (negative index) or right list (zero or positive
00030     index).
00031 
00032 SourceFiles
00033     BiIndirectListI.H
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef BiIndirectList_H
00038 #define BiIndirectList_H
00039 
00040 #include "List.H"
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 namespace Foam
00045 {
00046 
00047 /*---------------------------------------------------------------------------*\
00048                            Class BiIndirectList Declaration
00049 \*---------------------------------------------------------------------------*/
00050 
00051 template<class T>
00052 class BiIndirectList
00053 {
00054     // Private data
00055 
00056         UList<T>& posList_;
00057         UList<T>& negList_;
00058         List<label> addressing_;
00059 
00060 
00061 public:
00062 
00063     // Constructors
00064 
00065         //- Construct given the complete lists and the addressing array
00066         inline BiIndirectList
00067         (
00068             const UList<T>& posList,
00069             const UList<T>& negList,
00070             const List<label>&
00071         );
00072 
00073 
00074     // Member Functions
00075 
00076         // Access
00077 
00078             inline label size() const;
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 i);
00086             inline static label negIndex(const label i);
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 "BiIndirectListI.H"
00115 
00116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00117 
00118 #endif
00119 
00120 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd