1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 \*---------------------------------------------------------------------------*/
27 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 inline CompactListList<T>::CompactListList()
40 inline CompactListList<T>::CompactListList(const label nRows, const label nData)
48 inline CompactListList<T>::CompactListList
61 inline autoPtr<CompactListList<T> > CompactListList<T>::clone() const
63 return autoPtr<CompactListList<T> >(new CompactListList<T>(*this));
67 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
70 inline label CompactListList<T>::size() const
72 return offsets_.size();
76 inline const List<label>& CompactListList<T>::offsets() const
82 inline List<label>& CompactListList<T>::offsets()
88 inline const List<T>& CompactListList<T>::m() const
94 inline List<T>& CompactListList<T>::m()
101 inline label CompactListList<T>::index(const label i, const label j) const
109 return offsets_[i-1] + j;
114 inline label CompactListList<T>::whichRow(const label i) const
116 if (i < 0 || i >= m_.size())
120 "CompactListList<T>::whichRow(const label i) const"
121 ) << "Index " << i << " outside 0.." << m_.size()
122 << abort(FatalError);
125 forAll(offsets_, rowI)
127 if (i < offsets_[rowI])
137 inline label CompactListList<T>::whichColumn(const label row, const label i)
140 return i - index(row, 0);
143 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
146 inline UList<T> CompactListList<T>::operator[](const label i)
150 return UList<T>(m_.begin(), offsets_[i]);
154 return UList<T>(&m_[offsets_[i-1]], offsets_[i] - offsets_[i-1]);
159 inline const UList<T> CompactListList<T>::operator[](const label i) const
163 return UList<T>(m_.begin(), offsets_[i]);
167 return UList<T>(&m_[offsets_[i-1]], offsets_[i] - offsets_[i-1]);
173 inline T& CompactListList<T>::operator()(const label i, const label j)
175 return m_[index(i, j)];
179 inline const T& CompactListList<T>::operator()
185 return m_[index(i, j)];
190 inline void CompactListList<T>::operator=(const T& t)
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 } // End namespace Foam
200 // ************************************************************************* //