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 \*---------------------------------------------------------------------------*/
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 inline Foam::CompactListList<T>::CompactListList()
36 inline Foam::CompactListList<T>::CompactListList
48 inline Foam::CompactListList<T>::CompactListList
61 inline Foam::autoPtr<Foam::CompactListList<T> >
62 Foam::CompactListList<T>::clone() const
64 return autoPtr<CompactListList<T> >(new CompactListList<T>(*this));
68 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
71 inline const Foam::CompactListList<T>& Foam::CompactListList<T>::null()
73 return *reinterpret_cast< CompactListList<T>* >(0);
78 inline Foam::label Foam::CompactListList<T>::size() const
80 return offsets_.size();
85 inline bool Foam::CompactListList<T>::empty() const
87 return offsets_.empty();
92 inline const Foam::List<Foam::label>& Foam::CompactListList<T>::offsets() const
99 inline Foam::List<Foam::label>& Foam::CompactListList<T>::offsets()
106 inline const Foam::List<T>& Foam::CompactListList<T>::m() const
113 inline Foam::List<T>& Foam::CompactListList<T>::m()
120 inline Foam::label Foam::CompactListList<T>::index
132 return offsets_[i-1] + j;
138 inline Foam::label Foam::CompactListList<T>::whichRow(const label i) const
140 if (i < 0 || i >= m_.size())
144 "CompactListList<T>::whichRow(const label) const"
145 ) << "Index " << i << " outside 0.." << m_.size()
146 << abort(FatalError);
149 forAll(offsets_, rowI)
151 if (i < offsets_[rowI])
162 inline Foam::label Foam::CompactListList<T>::whichColumn
168 return i - index(row, 0);
173 inline Foam::Xfer<Foam::CompactListList<T> > Foam::CompactListList<T>::xfer()
175 return xferMove(*this);
180 inline void Foam::CompactListList<T>::resize(const label nRows)
182 this->setSize(nRows);
187 inline void Foam::CompactListList<T>::resize
193 this->setSize(nRows, nData);
198 inline void Foam::CompactListList<T>::resize
205 this->setSize(nRows, nData, t);
210 inline void Foam::CompactListList<T>::resize(const UList<label>& rowSizes)
212 this->setSize(rowSizes);
216 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
219 inline Foam::UList<T> Foam::CompactListList<T>::operator[]
226 return UList<T>(m_.begin(), offsets_[i]);
230 return UList<T>(&m_[offsets_[i-1]], offsets_[i] - offsets_[i-1]);
236 inline const Foam::UList<T> Foam::CompactListList<T>::operator[]
243 return UList<T>(m_.begin(), offsets_[i]);
247 return UList<T>(&m_[offsets_[i-1]], offsets_[i] - offsets_[i-1]);
253 inline T& Foam::CompactListList<T>::operator()
259 return m_[index(i, j)];
264 inline const T& Foam::CompactListList<T>::operator()
270 return m_[index(i, j)];
275 inline void Foam::CompactListList<T>::operator=(const T& t)
281 // ************************************************************************* //