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
29 Base doubly-linked list.
34 \*---------------------------------------------------------------------------*/
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 /*---------------------------------------------------------------------------*\
48 Class DLListBase Declaration
49 \*---------------------------------------------------------------------------*/
59 //- Pointer to next entry in list
65 //- Check if the link is registered with the DLListBase
66 inline bool registered() const;
68 //- Deregister the link after removal
69 inline void deregister();
77 //- first_ points to first element and last_ points to last element.
80 //- Number of elements in in list
84 // Private member functions
86 //- Disallow default bitwise copy construct
87 DLListBase(const DLListBase&);
89 //- Disallow default bitwise assignment
90 void operator=(const DLListBase&);
95 // Forward declaration of STL iterators
98 friend class iterator;
100 class const_iterator;
101 friend class const_iterator;
109 //- Construct given initial entry
110 inline DLListBase(link*);
122 //- Return number of elements in list
123 inline label size() const;
125 //- Return first entry
126 inline link* first();
128 //- Return const access to first entry
129 inline const link* first() const;
131 //- Return last entry
134 //- Return const access to last entry
135 inline const link* last() const;
140 //- Add at head of list
143 //- Add at tail of list
146 //- Swap this element with the one above unless it is at the top
149 //- Swap this element with the one below unless it is at the bottom
150 bool swapDown(link*);
152 //- Remove and return head
155 //- Remove and return element
158 // Remove and return element specified by iterator
159 inline link* remove(iterator&);
161 //- Replace oldLink with newLink and return element
162 link* replace(link* oldLink, link* newLink);
164 //- Replace oldIter with newLink and return element
165 inline link* replace(iterator& oldIter, link* newLink);
176 friend class DLListBase;
177 friend class const_iterator;
181 //- Reference to the list this is an iterator for
182 DLListBase& curList_;
192 //- Construct for a given DLListBase and link
193 inline iterator(DLListBase&, link*);
195 //- Construct for a given DLListBase
196 // setting element and link to NULL.
197 // Only used to create endIter
198 inline iterator(DLListBase&);
202 inline void operator=(const iterator&);
204 inline bool operator==(const iterator&) const;
205 inline bool operator!=(const iterator&) const;
207 inline link& operator*();
209 inline iterator& operator++();
210 inline iterator operator++(int);
213 inline iterator begin();
215 //- iterator returned by end()
216 static iterator endIter;
218 inline const iterator& end();
221 // STL const_iterator
223 //- An STL const_iterator
228 //- Reference to the list this is an iterator for
229 const DLListBase& curList_;
232 const link* curElmt_;
236 //- Construct for a given DLListBase and link
237 inline const_iterator(const DLListBase&, const link*);
239 //- Construct from a non-const iterator
240 inline const_iterator(const iterator&);
244 inline void operator=(const const_iterator&);
246 inline bool operator==(const const_iterator&) const;
247 inline bool operator!=(const const_iterator&) const;
249 inline const link& operator*();
251 inline const_iterator& operator++();
252 inline const_iterator operator++(int);
255 inline const_iterator begin() const;
257 //- const_iterator returned by end()
258 static const_iterator endConstIter;
260 inline const const_iterator& end() const;
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 } // End namespace Foam
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270 #include "DLListBaseI.H"
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 // ************************************************************************* //