1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 inline Foam::BiIndirectList<T>::BiIndirectList
32 const UList<T>& posList,
33 const UList<T>& negList,
34 const UList<label>& addr
37 posList_(const_cast<UList<T>&>(posList)),
38 negList_(const_cast<UList<T>&>(negList)),
43 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
46 inline Foam::label Foam::BiIndirectList<T>::size() const
48 return addressing_.size();
53 inline bool Foam::BiIndirectList<T>::empty() const
55 return addressing_.empty();
60 inline const Foam::UList<T>& Foam::BiIndirectList<T>::posList() const
67 inline const Foam::UList<T>& Foam::BiIndirectList<T>::negList() const
74 inline const Foam::List<Foam::label>& Foam::BiIndirectList<T>::addressing()
82 inline Foam::List<Foam::label>& Foam::BiIndirectList<T>::addressing()
89 inline Foam::label Foam::BiIndirectList<T>::posIndex(const label i)
96 inline Foam::label Foam::BiIndirectList<T>::negIndex(const label i)
102 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
105 inline Foam::List<T> Foam::BiIndirectList<T>::operator()() const
107 List<T> result(size());
111 result[i] = operator[](i);
119 inline T& Foam::BiIndirectList<T>::operator[](const label i)
121 label index = addressing_[i];
125 return posList_[index];
129 return negList_[-index-1];
135 inline const T& Foam::BiIndirectList<T>::operator[](const label i) const
137 label index = addressing_[i];
141 return posList_[index];
145 return negList_[-index-1];
151 inline void Foam::BiIndirectList<T>::operator=(const UList<T>& ae)
153 if (addressing_.size() != ae.size())
155 FatalErrorIn("BiIndirectList<T>::operator=(const UList<T>&)")
156 << "Addressing and list of addressed elements "
157 "have different sizes: "
158 << addressing_.size() << " " << ae.size()
159 << abort(FatalError);
162 forAll(addressing_, i)
164 operator[](i) = ae[i];
170 inline void Foam::BiIndirectList<T>::operator=(const T& t)
172 forAll(addressing_, i)
179 // ************************************************************************* //