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 #include <OpenFOAM/error.H>
00027
00028
00029
00030 inline Foam::DLListBase::link::link()
00031 :
00032 prev_(0),
00033 next_(0)
00034 {}
00035
00036
00037 inline Foam::DLListBase::DLListBase()
00038 :
00039 first_(0),
00040 last_(0),
00041 nElmts_(0)
00042 {}
00043
00044
00045 inline Foam::DLListBase::DLListBase(link* a)
00046 :
00047 first_(a),
00048 last_(a),
00049 nElmts_(1)
00050 {
00051 a->prev_ = a;
00052 a->next_ = a;
00053 }
00054
00055
00056
00057
00058 inline Foam::DLListBase::~DLListBase()
00059 {}
00060
00061
00062
00063
00064 inline bool Foam::DLListBase::link::registered() const
00065 {
00066 return prev_ != 0 && next_ != 0;
00067 }
00068
00069
00070 inline void Foam::DLListBase::link::deregister()
00071 {
00072 prev_ = 0;
00073 next_ = 0;
00074 }
00075
00076
00077 inline Foam::label Foam::DLListBase::size() const
00078 {
00079 return nElmts_;
00080 }
00081
00082
00083 inline bool Foam::DLListBase::empty() const
00084 {
00085 return !nElmts_;
00086 }
00087
00088
00089 inline Foam::DLListBase::link*
00090 Foam::DLListBase::first()
00091 {
00092 if (!nElmts_)
00093 {
00094 FatalErrorIn("DLListBase::first()")
00095 << "list is empty"
00096 << abort(FatalError);
00097 }
00098 return first_;
00099 }
00100
00101
00102 inline const Foam::DLListBase::link*
00103 Foam::DLListBase::first() const
00104 {
00105 if (!nElmts_)
00106 {
00107 FatalErrorIn("DLListBase::first() const")
00108 << "list is empty"
00109 << abort(FatalError);
00110 }
00111 return first_;
00112 }
00113
00114
00115 inline Foam::DLListBase::link*
00116 Foam::DLListBase::last()
00117 {
00118 if (!nElmts_)
00119 {
00120 FatalErrorIn("DLListBase::last()")
00121 << "list is empty"
00122 << abort(FatalError);
00123 }
00124 return last_;
00125 }
00126
00127
00128 inline const Foam::DLListBase::link*
00129 Foam::DLListBase::last() const
00130 {
00131 if (!nElmts_)
00132 {
00133 FatalErrorIn("DLListBase::last() const")
00134 << "list is empty"
00135 << abort(FatalError);
00136 }
00137 return last_;
00138 }
00139
00140
00141 inline void Foam::DLListBase::clear()
00142 {
00143 first_ = 0;
00144 last_ = 0;
00145 nElmts_ = 0;
00146 }
00147
00148
00149 inline void Foam::DLListBase::transfer(DLListBase& lst)
00150 {
00151 first_ = lst.first_;
00152 last_ = lst.last_;
00153 nElmts_ = lst.nElmts_;
00154
00155 lst.clear();
00156 }
00157
00158
00159 inline Foam::DLListBase::link*
00160 Foam::DLListBase::remove
00161 (
00162 DLListBase::iterator& it
00163 )
00164 {
00165 return remove(it.curElmt_);
00166 }
00167
00168
00169 inline Foam::DLListBase::link*
00170 Foam::DLListBase::replace
00171 (
00172 DLListBase::iterator& oldIter,
00173 DLListBase::link* newLink
00174 )
00175 {
00176 return replace(oldIter.curElmt_, newLink);
00177 }
00178
00179
00180
00181
00182 inline Foam::DLListBase::iterator::iterator(DLListBase& s, link* elmt)
00183 :
00184 curList_(s),
00185 curElmt_(elmt),
00186 curLink_(*curElmt_)
00187 {}
00188
00189
00190 inline Foam::DLListBase::iterator::iterator(DLListBase& s)
00191 :
00192 curList_(s),
00193 curElmt_(NULL),
00194 curLink_()
00195 {}
00196
00197
00198 inline void Foam::DLListBase::iterator::operator=(const iterator& iter)
00199 {
00200 curElmt_ = iter.curElmt_;
00201 curLink_ = iter.curLink_;
00202 }
00203
00204
00205 inline bool Foam::DLListBase::iterator::operator==(const iterator& iter) const
00206 {
00207 return curElmt_ == iter.curElmt_;
00208 }
00209
00210
00211 inline bool Foam::DLListBase::iterator::operator!=(const iterator& iter) const
00212 {
00213 return curElmt_ != iter.curElmt_;
00214 }
00215
00216
00217 inline Foam::DLListBase::link&
00218 Foam::DLListBase::iterator::operator*()
00219 {
00220 return *curElmt_;
00221 }
00222
00223
00224 inline Foam::DLListBase::iterator&
00225 Foam::DLListBase::iterator::operator++()
00226 {
00227
00228
00229 if (curLink_.next_ == curElmt_ || curList_.last_ == 0)
00230 {
00231 curElmt_ = 0;
00232 }
00233 else
00234 {
00235 curElmt_ = curLink_.next_;
00236 curLink_ = *curElmt_;
00237 }
00238
00239 return *this;
00240 }
00241
00242
00243 inline Foam::DLListBase::iterator
00244 Foam::DLListBase::iterator::operator++(int)
00245 {
00246 iterator tmp = *this;
00247 ++*this;
00248 return tmp;
00249 }
00250
00251
00252 inline Foam::DLListBase::iterator
00253 Foam::DLListBase::begin()
00254 {
00255 if (size())
00256 {
00257 return iterator(*this, first());
00258 }
00259 else
00260 {
00261 return endIter_;
00262 }
00263 }
00264
00265
00266 inline const Foam::DLListBase::iterator& Foam::DLListBase::end()
00267 {
00268 return endIter_;
00269 }
00270
00271
00272
00273
00274 inline Foam::DLListBase::const_iterator::const_iterator
00275 (
00276 const DLListBase& s,
00277 const link* elmt
00278 )
00279 :
00280 curList_(s),
00281 curElmt_(elmt)
00282 {}
00283
00284
00285 inline Foam::DLListBase::const_iterator::const_iterator(const iterator& iter)
00286 :
00287 curList_(iter.curList_),
00288 curElmt_(iter.curElmt_)
00289 {}
00290
00291
00292 inline void Foam::DLListBase::const_iterator::operator=
00293 (
00294 const const_iterator& iter
00295 )
00296 {
00297 curElmt_ = iter.curElmt_;
00298 }
00299
00300
00301 inline bool Foam::DLListBase::const_iterator::operator==
00302 (
00303 const const_iterator& iter
00304 ) const
00305 {
00306 return curElmt_ == iter.curElmt_;
00307 }
00308
00309
00310 inline bool Foam::DLListBase::const_iterator::operator!=
00311 (
00312 const const_iterator& iter
00313 ) const
00314 {
00315 return curElmt_ != iter.curElmt_;
00316 }
00317
00318
00319 inline const Foam::DLListBase::link&
00320 Foam::DLListBase::const_iterator::operator*()
00321 {
00322 return *curElmt_;
00323 }
00324
00325
00326 inline Foam::DLListBase::const_iterator&
00327 Foam::DLListBase::const_iterator::operator++()
00328 {
00329 if (curElmt_ == curList_.last_)
00330 {
00331 curElmt_ = 0;
00332 }
00333 else
00334 {
00335 curElmt_ = curElmt_->next_;
00336 }
00337
00338 return *this;
00339 }
00340
00341
00342 inline Foam::DLListBase::const_iterator
00343 Foam::DLListBase::const_iterator::operator++(int)
00344 {
00345 const_iterator tmp = *this;
00346 ++*this;
00347 return tmp;
00348 }
00349
00350
00351 inline Foam::DLListBase::const_iterator
00352 Foam::DLListBase::cbegin() const
00353 {
00354 if (size())
00355 {
00356 return const_iterator(*this, first());
00357 }
00358 else
00359 {
00360 return endConstIter_;
00361 }
00362 }
00363
00364
00365 inline const Foam::DLListBase::const_iterator&
00366 Foam::DLListBase::cend() const
00367 {
00368 return endConstIter_;
00369 }
00370
00371
00372 inline Foam::DLListBase::const_iterator
00373 Foam::DLListBase::begin() const
00374 {
00375 return this->cbegin();
00376 }
00377
00378
00379 inline const Foam::DLListBase::const_iterator&
00380 Foam::DLListBase::end() const
00381 {
00382 return endConstIter_;
00383 }
00384
00385
00386