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
29 Base singly-linked list.
34 \*---------------------------------------------------------------------------*/
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 /*---------------------------------------------------------------------------*\
49 Class SLListBase Declaration
50 \*---------------------------------------------------------------------------*/
60 //- Pointer to next entry in list
66 //- Construct given pointer to another link
75 //- last_ points to last element
76 // last_->next_ points to first element, i.e. circular storage
79 //- Number of elements in in list
82 // Private member functions
84 //- Disallow default bitwise copy construct
85 SLListBase(const SLListBase&);
87 //- Disallow default bitwise assignment
88 void operator=(const SLListBase&);
93 // Forward declaration of STL iterators
96 friend class iterator;
99 friend class const_iterator;
107 //- Construct given initial entry
108 inline SLListBase(link*);
120 //- Return number of elements in list
121 inline label size() const;
123 //- Return true if the list is empty
124 inline bool empty() const;
126 //- Return first entry
127 inline link* first();
129 //- Return const access to first entry
130 inline const link* first() const;
132 //- Return last entry
135 //- Return const access to last entry
136 inline const link* last() const;
141 //- Add at head of list
144 //- Add at tail of list
147 //- Remove and return head
150 // Remove and return element
153 // Remove and return element specified by iterator
154 inline link* remove(iterator&);
159 //- Transfer the contents of the argument into this List
160 // and annull the argument list.
161 inline void transfer(SLListBase&);
165 //- An STL-conforming iterator
168 friend class SLListBase;
169 friend class const_iterator;
173 //- Reference to the list this is an iterator for
174 SLListBase& curList_;
182 // Private Member Functions
184 //- Construct for a given SLListBase with NULL element and link.
185 // Only used to create endIter
186 inline iterator(SLListBase&);
190 //- Construct for a given SLListBase and link
191 inline iterator(SLListBase&, link*);
195 inline void operator=(const iterator&);
197 inline bool operator==(const iterator&) const;
198 inline bool operator!=(const iterator&) const;
200 inline link& operator*();
202 inline iterator& operator++();
203 inline iterator operator++(int);
206 inline iterator begin();
207 inline const iterator& end();
210 // STL const_iterator
212 //- An STL-conforming const_iterator
217 //- Reference to the list this is an iterator for
218 const SLListBase& curList_;
221 const link* curElmt_;
225 //- Construct for a given SLListBase and link
226 inline const_iterator(const SLListBase&, const link*);
228 //- Construct from a non-const iterator
229 inline const_iterator(const iterator&);
234 inline void operator=(const const_iterator&);
236 inline bool operator==(const const_iterator&) const;
237 inline bool operator!=(const const_iterator&) const;
239 inline const link& operator*();
241 inline const_iterator& operator++();
242 inline const_iterator operator++(int);
245 inline const_iterator cbegin() const;
246 inline const const_iterator& cend() const;
248 inline const_iterator begin() const;
249 inline const const_iterator& end() const;
254 //- iterator returned by end()
255 static iterator endIter_;
257 //- const_iterator returned by end()
258 static const_iterator endConstIter_;
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 } // End namespace Foam
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 #include "SLListBaseI.H"
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 // ************************************************************************* //