1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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 UList<label>& addr
36 posList_(const_cast<UList<T>&>(posList)),
37 negList_(const_cast<UList<T>&>(negList)),
42 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
45 inline Foam::label Foam::BiIndirectList<T>::size() const
47 return addressing_.size();
52 inline bool Foam::BiIndirectList<T>::empty() const
54 return addressing_.empty();
59 inline const Foam::UList<T>& Foam::BiIndirectList<T>::posList() const
66 inline const Foam::UList<T>& Foam::BiIndirectList<T>::negList() const
73 inline const Foam::List<Foam::label>& Foam::BiIndirectList<T>::addressing()
81 inline Foam::List<Foam::label>& Foam::BiIndirectList<T>::addressing()
88 inline Foam::label Foam::BiIndirectList<T>::posIndex(const label i)
95 inline Foam::label Foam::BiIndirectList<T>::negIndex(const label i)
101 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
104 inline Foam::List<T> Foam::BiIndirectList<T>::operator()() const
106 List<T> result(size());
110 result[i] = operator[](i);
118 inline T& Foam::BiIndirectList<T>::operator[](const label i)
120 label index = addressing_[i];
124 return posList_[index];
128 return negList_[-index-1];
134 inline const T& Foam::BiIndirectList<T>::operator[](const label i) const
136 label index = addressing_[i];
140 return posList_[index];
144 return negList_[-index-1];
150 inline void Foam::BiIndirectList<T>::operator=(const UList<T>& ae)
152 if (addressing_.size() != ae.size())
154 FatalErrorIn("BiIndirectList<T>::operator=(const UList<T>&)")
155 << "Addressing and list of addressed elements "
156 "have different sizes: "
157 << addressing_.size() << " " << ae.size()
158 << abort(FatalError);
161 forAll(addressing_, i)
163 operator[](i) = ae[i];
169 inline void Foam::BiIndirectList<T>::operator=(const T& t)
171 forAll(addressing_, i)
178 // ************************************************************************* //