1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
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::UIndirectList<T>::UIndirectList
31 const UList<T>& completeList,
32 const labelUList& 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 T& Foam::UIndirectList<T>::first()
59 return completeList_[addressing_.first()];
64 inline const T& Foam::UIndirectList<T>::first() const
66 return completeList_[addressing_.first()];
71 inline T& Foam::UIndirectList<T>::last()
73 return completeList_[addressing_.last()];
78 inline const T& Foam::UIndirectList<T>::last() const
80 return completeList_[addressing_.last()];
85 inline const Foam::UList<T>& Foam::UIndirectList<T>::completeList() const
92 inline const Foam::List<Foam::label>& Foam::UIndirectList<T>::addressing() const
98 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
101 inline Foam::List<T> Foam::UIndirectList<T>::operator()() const
103 List<T> result(size());
107 result[i] = operator[](i);
115 inline T& Foam::UIndirectList<T>::operator[](const label i)
117 return completeList_[addressing_[i]];
122 inline const T& Foam::UIndirectList<T>::operator[](const label i) const
124 return completeList_[addressing_[i]];
129 inline void Foam::UIndirectList<T>::operator=(const UList<T>& ae)
131 if (addressing_.size() != ae.size())
133 FatalErrorIn("UIndirectList<T>::operator=(const UList<T>&)")
134 << "Addressing and list of addressed elements "
135 "have different sizes: "
136 << addressing_.size() << " " << ae.size()
137 << abort(FatalError);
140 forAll(addressing_, i)
142 completeList_[addressing_[i]] = ae[i];
148 inline void Foam::UIndirectList<T>::operator=(const T& t)
150 forAll(addressing_, i)
152 completeList_[addressing_[i]] = t;
157 // ************************************************************************* //