OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide 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-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::BiIndirectList
00027 
00028 Description
00029     Indexes into negList (negative index) or posList (zero or positive index).
00030 
00031 SourceFiles
00032     BiIndirectListI.H
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef BiIndirectList_H
00037 #define BiIndirectList_H
00038 
00039 #include "List.H"
00040 
00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00042 
00043 namespace Foam
00044 {
00045 
00046 /*---------------------------------------------------------------------------*\
00047                            Class BiIndirectList Declaration
00048 \*---------------------------------------------------------------------------*/
00049 
00050 template<class T>
00051 class BiIndirectList
00052 {
00053     // Private data
00054 
00055         UList<T>& posList_;
00056         UList<T>& negList_;
00057         List<label> addressing_;
00058 
00059 
00060 public:
00061 
00062     // Constructors
00063 
00064         //- Construct given the complete lists and the addressing array
00065         inline BiIndirectList
00066         (
00067             const UList<T>& posList,
00068             const UList<T>& negList,
00069             const UList<label>&
00070         );
00071 
00072 
00073     // Member Functions
00074 
00075         // Access
00076 
00077             inline label size() const;
00078             inline bool  empty() const;
00079 
00080             inline const UList<T>& posList() const;
00081             inline const UList<T>& negList() const;
00082             inline const List<label>& addressing() const;
00083             inline List<label>& addressing();
00084 
00085             //- Calculate index given whether index is into posList or negList
00086             inline static label posIndex(const label);
00087             inline static label negIndex(const label);
00088 
00089 
00090         // Member Operators
00091 
00092             //- Return the addressed elements as a List
00093             inline List<T> operator()() const;
00094 
00095             //- Return non-const access to an element
00096             inline T& operator[](const label);
00097 
00098             //- Return const access to an element
00099             inline const T& operator[](const label) const;
00100 
00101             //- Assignment from UList of addressed elements
00102             inline void operator=(const UList<T>&);
00103 
00104             //- Assignment of all entries to the given value
00105             inline void operator=(const T&);
00106 };
00107 
00108 
00109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00110 
00111 } // End namespace Foam
00112 
00113 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00114 
00115 #include "BiIndirectListI.H"
00116 
00117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00118 
00119 #endif
00120 
00121 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd