1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 inline Foam::BiIndirectList<T>::BiIndirectList
31 const UList<T>& posList,
32 const UList<T>& negList,
33 const labelUList& addr
36 posList_(const_cast<UList<T>&>(posList)),
37 negList_(const_cast<UList<T>&>(negList)),
43 inline Foam::BiIndirectList<T>::BiIndirectList
45 const UList<T>& posList,
46 const UList<T>& negList,
47 const Xfer<List<label> >& addr
50 posList_(const_cast<UList<T>&>(posList)),
51 negList_(const_cast<UList<T>&>(negList)),
56 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
59 inline Foam::label Foam::BiIndirectList<T>::size() const
61 return addressing_.size();
66 inline bool Foam::BiIndirectList<T>::empty() const
68 return addressing_.empty();
73 inline const Foam::UList<T>& Foam::BiIndirectList<T>::posList() const
80 inline const Foam::UList<T>& Foam::BiIndirectList<T>::negList() const
87 inline const Foam::List<Foam::label>& Foam::BiIndirectList<T>::addressing()
95 inline void Foam::BiIndirectList<T>::resetAddressing
97 const labelUList& addr
105 inline void Foam::BiIndirectList<T>::resetAddressing
107 const Xfer<List<label> >& addr
110 addressing_.transfer(addr());
115 inline Foam::label Foam::BiIndirectList<T>::posIndex(const label i)
122 inline Foam::label Foam::BiIndirectList<T>::negIndex(const label i)
128 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
131 inline Foam::List<T> Foam::BiIndirectList<T>::operator()() const
133 List<T> result(size());
137 result[i] = operator[](i);
145 inline T& Foam::BiIndirectList<T>::operator[](const label i)
147 label index = addressing_[i];
151 return posList_[index];
155 return negList_[-index-1];
161 inline const T& Foam::BiIndirectList<T>::operator[](const label i) const
163 label index = addressing_[i];
167 return posList_[index];
171 return negList_[-index-1];
177 inline void Foam::BiIndirectList<T>::operator=(const UList<T>& ae)
179 if (addressing_.size() != ae.size())
181 FatalErrorIn("BiIndirectList<T>::operator=(const UList<T>&)")
182 << "Addressing and list of addressed elements "
183 "have different sizes: "
184 << addressing_.size() << " " << ae.size()
185 << abort(FatalError);
188 forAll(addressing_, i)
190 operator[](i) = ae[i];
196 inline void Foam::BiIndirectList<T>::operator=(const T& t)
198 forAll(addressing_, i)
205 // ************************************************************************* //