CompactListListI.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 template<class T>
00031 inline Foam::CompactListList<T>::CompactListList()
00032 {}
00033
00034
00035 template<class T>
00036 inline Foam::CompactListList<T>::CompactListList
00037 (
00038 const label nRows,
00039 const label nData
00040 )
00041 :
00042 offsets_(nRows, 0),
00043 m_(nData)
00044 {}
00045
00046
00047 template<class T>
00048 inline Foam::CompactListList<T>::CompactListList
00049 (
00050 const label nRows,
00051 const label nData,
00052 const T& t
00053 )
00054 :
00055 offsets_(nRows, 0),
00056 m_(nData, t)
00057 {}
00058
00059
00060 template<class T>
00061 inline Foam::autoPtr<Foam::CompactListList<T> >
00062 Foam::CompactListList<T>::clone() const
00063 {
00064 return autoPtr<CompactListList<T> >(new CompactListList<T>(*this));
00065 }
00066
00067
00068
00069
00070 template<class T>
00071 inline const Foam::CompactListList<T>& Foam::CompactListList<T>::null()
00072 {
00073 return *reinterpret_cast< CompactListList<T>* >(0);
00074 }
00075
00076
00077 template<class T>
00078 inline Foam::label Foam::CompactListList<T>::size() const
00079 {
00080 return offsets_.size();
00081 }
00082
00083
00084 template<class T>
00085 inline bool Foam::CompactListList<T>::empty() const
00086 {
00087 return offsets_.empty();
00088 }
00089
00090
00091 template<class T>
00092 inline const Foam::List<Foam::label>& Foam::CompactListList<T>::offsets() const
00093 {
00094 return offsets_;
00095 }
00096
00097
00098 template<class T>
00099 inline Foam::List<Foam::label>& Foam::CompactListList<T>::offsets()
00100 {
00101 return offsets_;
00102 }
00103
00104
00105 template<class T>
00106 inline const Foam::List<T>& Foam::CompactListList<T>::m() const
00107 {
00108 return m_;
00109 }
00110
00111
00112 template<class T>
00113 inline Foam::List<T>& Foam::CompactListList<T>::m()
00114 {
00115 return m_;
00116 }
00117
00118
00119 template<class T>
00120 inline Foam::label Foam::CompactListList<T>::index
00121 (
00122 const label i,
00123 const label j
00124 ) const
00125 {
00126 if (i == 0)
00127 {
00128 return j;
00129 }
00130 else
00131 {
00132 return offsets_[i-1] + j;
00133 }
00134 }
00135
00136
00137 template<class T>
00138 inline Foam::label Foam::CompactListList<T>::whichRow(const label i) const
00139 {
00140 if (i < 0 || i >= m_.size())
00141 {
00142 FatalErrorIn
00143 (
00144 "CompactListList<T>::whichRow(const label) const"
00145 ) << "Index " << i << " outside 0.." << m_.size()
00146 << abort(FatalError);
00147 }
00148
00149 forAll(offsets_, rowI)
00150 {
00151 if (i < offsets_[rowI])
00152 {
00153 return rowI;
00154 }
00155 }
00156
00157 return -1;
00158 }
00159
00160
00161 template<class T>
00162 inline Foam::label Foam::CompactListList<T>::whichColumn
00163 (
00164 const label row,
00165 const label i
00166 ) const
00167 {
00168 return i - index(row, 0);
00169 }
00170
00171
00172 template<class T>
00173 inline Foam::Xfer<Foam::CompactListList<T> > Foam::CompactListList<T>::xfer()
00174 {
00175 return xferMove(*this);
00176 }
00177
00178
00179 template<class T>
00180 inline void Foam::CompactListList<T>::resize(const label nRows)
00181 {
00182 this->setSize(nRows);
00183 }
00184
00185
00186 template<class T>
00187 inline void Foam::CompactListList<T>::resize
00188 (
00189 const label nRows,
00190 const label nData
00191 )
00192 {
00193 this->setSize(nRows, nData);
00194 }
00195
00196
00197 template<class T>
00198 inline void Foam::CompactListList<T>::resize
00199 (
00200 const label nRows,
00201 const label nData,
00202 const T& t
00203 )
00204 {
00205 this->setSize(nRows, nData, t);
00206 }
00207
00208
00209 template<class T>
00210 inline void Foam::CompactListList<T>::resize(const UList<label>& rowSizes)
00211 {
00212 this->setSize(rowSizes);
00213 }
00214
00215
00216
00217
00218 template<class T>
00219 inline Foam::UList<T> Foam::CompactListList<T>::operator[]
00220 (
00221 const label i
00222 )
00223 {
00224 if (i == 0)
00225 {
00226 return UList<T>(m_.begin(), offsets_[i]);
00227 }
00228 else
00229 {
00230 return UList<T>(&m_[offsets_[i-1]], offsets_[i] - offsets_[i-1]);
00231 }
00232 }
00233
00234
00235 template<class T>
00236 inline const Foam::UList<T> Foam::CompactListList<T>::operator[]
00237 (
00238 const label i
00239 ) const
00240 {
00241 if (i == 0)
00242 {
00243 return UList<T>(m_.begin(), offsets_[i]);
00244 }
00245 else
00246 {
00247 return UList<T>(&m_[offsets_[i-1]], offsets_[i] - offsets_[i-1]);
00248 }
00249 }
00250
00251
00252 template<class T>
00253 inline T& Foam::CompactListList<T>::operator()
00254 (
00255 const label i,
00256 const label j
00257 )
00258 {
00259 return m_[index(i, j)];
00260 }
00261
00262
00263 template<class T>
00264 inline const T& Foam::CompactListList<T>::operator()
00265 (
00266 const label i,
00267 const label j
00268 ) const
00269 {
00270 return m_[index(i, j)];
00271 }
00272
00273
00274 template<class T>
00275 inline void Foam::CompactListList<T>::operator=(const T& t)
00276 {
00277 m_ = t;
00278 }
00279
00280
00281
Copyright © 2000-2009 OpenCFD Ltd