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::UIndirectList<T>::UIndirectList
31 const UList<T>& completeList,
32 const UList<label>& addr
35 completeList_(const_cast<UList<T>&>(completeList)),
40 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
43 inline Foam::label Foam::UIndirectList<T>::size() const
45 return addressing_.size();
50 inline bool Foam::UIndirectList<T>::empty() const
52 return addressing_.empty();
57 inline const Foam::UList<T>& Foam::UIndirectList<T>::completeList() const
64 inline const Foam::List<Foam::label>& Foam::UIndirectList<T>::addressing() const
70 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
73 inline Foam::List<T> Foam::UIndirectList<T>::operator()() const
75 List<T> result(size());
79 result[i] = operator[](i);
87 inline T& Foam::UIndirectList<T>::operator[](const label i)
89 return completeList_[addressing_[i]];
94 inline const T& Foam::UIndirectList<T>::operator[](const label i) const
96 return completeList_[addressing_[i]];
101 inline void Foam::UIndirectList<T>::operator=(const UList<T>& ae)
103 if (addressing_.size() != ae.size())
105 FatalErrorIn("UIndirectList<T>::operator=(const UList<T>&)")
106 << "Addressing and list of addressed elements "
107 "have different sizes: "
108 << addressing_.size() << " " << ae.size()
109 << abort(FatalError);
112 forAll(addressing_, i)
114 completeList_[addressing_[i]] = ae[i];
120 inline void Foam::UIndirectList<T>::operator=(const T& t)
122 forAll(addressing_, i)
124 completeList_[addressing_[i]] = t;
129 // ************************************************************************* //