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 \*---------------------------------------------------------------------------*/
29 #include "DLListBase.H"
30 #include "IOstreams.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 DLListBase::iterator DLListBase::endIter
42 const_cast<DLListBase&>(static_cast<const DLListBase&>(DLListBase()))
45 DLListBase::const_iterator DLListBase::endConstIter
47 static_cast<const DLListBase&>(DLListBase()),
48 reinterpret_cast<const link*>(NULL)
52 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
54 void DLListBase::insert(DLListBase::link* a)
74 void DLListBase::append(DLListBase::link* a)
94 bool DLListBase::swapUp(DLListBase::link* a)
112 a->next_->prev_ = ap;
117 ap->prev_->next_ = a;
120 a->prev_ = ap->prev_;
123 ap->next_ = a->next_;
135 bool DLListBase::swapDown(DLListBase::link* a)
153 a->prev_->next_ = an;
158 an->next_->prev_ = a;
161 an->prev_ = a->prev_;
164 a->next_ = an->next_;
176 DLListBase::link* DLListBase::removeHead()
182 FatalErrorIn("void DLListBase::removeHead()")
183 << "remove from empty list"
184 << abort(FatalError);
187 DLListBase::link* f = first_;
200 DLListBase::link* DLListBase::remove(DLListBase::link* l)
206 if (l == first_ && first_ == last_)
211 else if (l == first_)
213 first_ = first_->next_;
214 first_->prev_ = first_;
218 last_ = last_->prev_;
219 last_->next_ = last_;
223 l->next_->prev_ = l->prev_;
224 l->prev_->next_ = l->next_;
232 DLListBase::link* DLListBase::replace
234 DLListBase::link* oldLink,
235 DLListBase::link* newLink
240 newLink->prev_ = oldLink->prev_;
241 newLink->next_ = oldLink->next_;
243 if (oldLink == first_ && first_ == last_)
248 else if (oldLink == first_)
251 newLink->next_->prev_ = newLink;
253 else if (oldLink == last_)
256 newLink->prev_->next_ = newLink;
260 newLink->prev_->next_ = newLink;
261 newLink->next_->prev_ = newLink;
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 } // End namespace Foam
273 // ************************************************************************* //