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 \*---------------------------------------------------------------------------*/
29 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
31 inline Foam::DLListBase::link::link()
38 inline Foam::DLListBase::DLListBase()
46 inline Foam::DLListBase::DLListBase(link* a)
57 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
59 inline Foam::DLListBase::~DLListBase()
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65 inline bool Foam::DLListBase::link::registered() const
67 return prev_ != 0 && next_ != 0;
71 inline void Foam::DLListBase::link::deregister()
78 inline Foam::label Foam::DLListBase::size() const
84 inline bool Foam::DLListBase::empty() const
90 inline Foam::DLListBase::link*
91 Foam::DLListBase::first()
95 FatalErrorIn("DLListBase::first()")
103 inline const Foam::DLListBase::link*
104 Foam::DLListBase::first() const
108 FatalErrorIn("DLListBase::first() const")
110 << abort(FatalError);
116 inline Foam::DLListBase::link*
117 Foam::DLListBase::last()
121 FatalErrorIn("DLListBase::last()")
123 << abort(FatalError);
129 inline const Foam::DLListBase::link*
130 Foam::DLListBase::last() const
134 FatalErrorIn("DLListBase::last() const")
136 << abort(FatalError);
142 inline void Foam::DLListBase::clear()
150 inline void Foam::DLListBase::transfer(DLListBase& lst)
154 nElmts_ = lst.nElmts_;
160 inline Foam::DLListBase::link*
161 Foam::DLListBase::remove
163 DLListBase::iterator& it
166 return remove(it.curElmt_);
170 inline Foam::DLListBase::link*
171 Foam::DLListBase::replace
173 DLListBase::iterator& oldIter,
174 DLListBase::link* newLink
177 return replace(oldIter.curElmt_, newLink);
181 // * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * * //
183 inline Foam::DLListBase::iterator::iterator(DLListBase& s, link* elmt)
191 inline Foam::DLListBase::iterator::iterator(DLListBase& s)
199 inline void Foam::DLListBase::iterator::operator=(const iterator& iter)
201 curElmt_ = iter.curElmt_;
202 curLink_ = iter.curLink_;
206 inline bool Foam::DLListBase::iterator::operator==(const iterator& iter) const
208 return curElmt_ == iter.curElmt_;
212 inline bool Foam::DLListBase::iterator::operator!=(const iterator& iter) const
214 return curElmt_ != iter.curElmt_;
218 inline Foam::DLListBase::link&
219 Foam::DLListBase::iterator::operator*()
225 inline Foam::DLListBase::iterator&
226 Foam::DLListBase::iterator::operator++()
228 // Check if the curElmt_ is the last element (if it points to itself)
229 // or if the list is empty because the last element may have been removed
230 if (curLink_.next_ == curElmt_ || curList_.last_ == 0)
236 curElmt_ = curLink_.next_;
237 curLink_ = *curElmt_;
244 inline Foam::DLListBase::iterator
245 Foam::DLListBase::iterator::operator++(int)
247 iterator tmp = *this;
253 inline Foam::DLListBase::iterator
254 Foam::DLListBase::begin()
258 return iterator(*this, first());
267 inline const Foam::DLListBase::iterator& Foam::DLListBase::end()
273 // * * * * * * * * * * * * * * STL const_iterator * * * * * * * * * * * * * //
275 inline Foam::DLListBase::const_iterator::const_iterator
286 inline Foam::DLListBase::const_iterator::const_iterator(const iterator& iter)
288 curList_(iter.curList_),
289 curElmt_(iter.curElmt_)
293 inline void Foam::DLListBase::const_iterator::operator=
295 const const_iterator& iter
298 curElmt_ = iter.curElmt_;
302 inline bool Foam::DLListBase::const_iterator::operator==
304 const const_iterator& iter
307 return curElmt_ == iter.curElmt_;
311 inline bool Foam::DLListBase::const_iterator::operator!=
313 const const_iterator& iter
316 return curElmt_ != iter.curElmt_;
320 inline const Foam::DLListBase::link&
321 Foam::DLListBase::const_iterator::operator*()
327 inline Foam::DLListBase::const_iterator&
328 Foam::DLListBase::const_iterator::operator++()
330 if (curElmt_ == curList_.last_)
336 curElmt_ = curElmt_->next_;
343 inline Foam::DLListBase::const_iterator
344 Foam::DLListBase::const_iterator::operator++(int)
346 const_iterator tmp = *this;
352 inline Foam::DLListBase::const_iterator
353 Foam::DLListBase::cbegin() const
357 return const_iterator(*this, first());
361 return endConstIter_;
366 inline const Foam::DLListBase::const_iterator&
367 Foam::DLListBase::cend() const
369 return endConstIter_;
373 inline Foam::DLListBase::const_iterator
374 Foam::DLListBase::begin() const
376 return this->cbegin();
380 inline const Foam::DLListBase::const_iterator&
381 Foam::DLListBase::end() const
383 return endConstIter_;
387 // ************************************************************************* //