Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
containers
LinkedLists
linkTypes
DLListBase
DLListBase.H
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
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
13
the Free Software Foundation, either version 3 of the License, or
14
(at your option) any later version.
15
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
19
for more details.
20
21
You should have received a copy of the GNU General Public License
22
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23
24
Class
25
Foam::DLListBase
26
27
Description
28
Base doubly-linked list.
29
30
SourceFiles
31
DLListBase.C
32
33
\*---------------------------------------------------------------------------*/
34
35
#ifndef DLListBase_H
36
#define DLListBase_H
37
38
#include <
OpenFOAM/bool.H
>
39
#include <
OpenFOAM/label.H
>
40
#include <
OpenFOAM/uLabel.H
>
41
42
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44
namespace
Foam
45
{
46
47
/*---------------------------------------------------------------------------*\
48
Class DLListBase Declaration
49
\*---------------------------------------------------------------------------*/
50
51
class
DLListBase
52
{
53
54
public
:
55
56
//- Link structure
57
struct
link
58
{
59
//- Pointer to next entry in list
60
link
*
prev_
, *
next_
;
61
62
//- Null construct
63
inline
link
();
64
65
//- Check if the link is registered with the DLListBase
66
inline
bool
registered
()
const
;
67
68
//- Deregister the link after removal
69
inline
void
deregister
();
70
};
71
72
73
private
:
74
75
// Private data
76
77
//- first_ points to first element and last_ points to last element.
78
link
*first_, *last_;
79
80
//- Number of elements in in list
81
label nElmts_;
82
83
84
// Private member functions
85
86
//- Disallow default bitwise copy construct
87
DLListBase
(
const
DLListBase
&);
88
89
//- Disallow default bitwise assignment
90
void
operator=(
const
DLListBase
&);
91
92
93
public
:
94
95
// Forward declaration of STL iterators
96
97
class
iterator
;
98
friend
class
iterator
;
99
100
class
const_iterator
;
101
friend
class
const_iterator
;
102
103
104
// Constructors
105
106
//- Null construct
107
inline
DLListBase
();
108
109
//- Construct given initial entry
110
inline
DLListBase
(
link
*);
111
112
113
// Destructor
114
115
~DLListBase
();
116
117
118
// Member Functions
119
120
// Access
121
122
//- Return number of elements in list
123
inline
label
size
()
const
;
124
125
//- Return true if the list is empty
126
inline
bool
empty
()
const
;
127
128
//- Return first entry
129
inline
link
*
first
();
130
131
//- Return const access to first entry
132
inline
const
link
*
first
()
const
;
133
134
//- Return last entry
135
inline
link
*
last
();
136
137
//- Return const access to last entry
138
inline
const
link
*
last
()
const
;
139
140
141
// Edit
142
143
//- Add at head of list
144
void
insert
(
link
*);
145
146
//- Add at tail of list
147
void
append
(
link
*);
148
149
//- Swap this element with the one above unless it is at the top
150
bool
swapUp
(
link
*);
151
152
//- Swap this element with the one below unless it is at the bottom
153
bool
swapDown
(
link
*);
154
155
//- Remove and return head
156
link
*
removeHead
();
157
158
//- Remove and return element
159
link
*
remove
(
link
*);
160
161
// Remove and return element specified by iterator
162
inline
link
*
remove
(
iterator
&);
163
164
//- Replace oldLink with newLink and return element
165
link
*
replace
(
link
* oldLink,
link
* newLink);
166
167
//- Replace oldIter with newLink and return element
168
inline
link
*
replace
(
iterator
& oldIter,
link
* newLink);
169
170
//- Clear the list
171
inline
void
clear
();
172
173
//- Transfer the contents of the argument into this List
174
// and annull the argument list.
175
inline
void
transfer
(
DLListBase
&);
176
177
// STL iterator
178
179
//- An STL-conforming iterator
180
class
iterator
181
{
182
friend
class
DLListBase
;
183
friend
class
const_iterator
;
184
185
// Private data
186
187
//- Reference to the list this is an iterator for
188
DLListBase
& curList_;
189
190
//- Current element
191
link
* curElmt_;
192
193
//- Copy of the link
194
link
curLink_;
195
196
// Private Member Functions
197
198
//- Construct for a given SLListBase with NULL element and link.
199
// Only used to create endIter
200
inline
iterator
(
DLListBase
&);
201
202
public
:
203
204
//- Construct for a given DLListBase and link
205
inline
iterator
(
DLListBase
&,
link
*);
206
207
// Member operators
208
209
inline
void
operator=
(
const
iterator
&);
210
211
inline
bool
operator==
(
const
iterator
&)
const
;
212
inline
bool
operator!=
(
const
iterator
&)
const
;
213
214
inline
link
&
operator*
();
215
216
inline
iterator
&
operator++
();
217
inline
iterator
operator++
(
int
);
218
};
219
220
inline
iterator
begin
();
221
inline
const
iterator
&
end
();
222
223
224
// STL const_iterator
225
226
//- An STL-conforming const_iterator
227
class
const_iterator
228
{
229
// Private data
230
231
//- Reference to the list this is an iterator for
232
const
DLListBase
& curList_;
233
234
//- Current element
235
const
link
* curElmt_;
236
237
public
:
238
239
//- Construct for a given DLListBase and link
240
inline
const_iterator
(
const
DLListBase
&,
const
link
*);
241
242
//- Construct from a non-const iterator
243
inline
const_iterator
(
const
iterator
&);
244
245
// Member operators
246
247
inline
void
operator=
(
const
const_iterator
&);
248
249
inline
bool
operator==
(
const
const_iterator
&)
const
;
250
inline
bool
operator!=
(
const
const_iterator
&)
const
;
251
252
inline
const
link
&
operator*
();
253
254
inline
const_iterator
&
operator++
();
255
inline
const_iterator
operator++
(
int
);
256
};
257
258
inline
const_iterator
cbegin
()
const
;
259
inline
const
const_iterator
&
cend
()
const
;
260
261
inline
const_iterator
begin
()
const
;
262
inline
const
const_iterator
&
end
()
const
;
263
264
private
:
265
266
//- iterator returned by end()
267
static
iterator
endIter_;
268
269
//- const_iterator returned by end()
270
static
const_iterator
endConstIter_;
271
272
};
273
274
275
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276
277
}
// End namespace Foam
278
279
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280
281
#include "
DLListBaseI.H
"
282
283
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284
285
#endif
286
287
// ************************ vim: set sw=4 sts=4 et: ************************ //