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
accessTypes
UILList
UILList.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::UILList
26
27
Description
28
Template class for intrusive linked lists.
29
30
SourceFiles
31
UILList.C
32
UILListIO.C
33
34
\*---------------------------------------------------------------------------*/
35
36
#ifndef UILList_H
37
#define UILList_H
38
39
#include <
OpenFOAM/label.H
>
40
#include <
OpenFOAM/uLabel.H
>
41
42
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44
namespace
Foam
45
{
46
47
class
Ostream;
48
49
// Forward declaration of friend functions and operators
50
51
template
<
class
LListBase,
class
T>
52
class
UILList;
53
54
template
<
class
LListBase,
class
T>
55
Ostream&
operator
<<
56
(
57
Ostream&,
58
const
UILList<LListBase, T>&
59
);
60
61
62
/*---------------------------------------------------------------------------*\
63
Class UILList Declaration
64
\*---------------------------------------------------------------------------*/
65
66
template
<
class
LListBase,
class
T>
67
class
UILList
68
:
69
public
LListBase
70
{
71
72
public
:
73
74
// Forward declaration of STL iterators
75
76
class
iterator
;
77
friend
class
iterator
;
78
79
class
const_iterator
;
80
friend
class
const_iterator
;
81
82
83
// Constructors
84
85
//- Null construct
86
UILList
()
87
{}
88
89
//- Construct given initial T
90
UILList
(
T
* a)
91
:
92
LListBase
(a)
93
{}
94
95
//- Construct as copy
96
UILList
(
const
UILList<LListBase, T>
&);
97
98
99
// Member Functions
100
101
// Access
102
103
//- Return the first entry
104
T
*
first
()
105
{
106
return
static_cast<
T
*
>
(
LListBase::first
());
107
}
108
109
//- Return the first entry
110
const
T
*
first
()
const
111
{
112
return
static_cast<
const
T
*
>
(
LListBase::first
());
113
}
114
115
//- Return the last entry
116
T
*
last
()
117
{
118
return
static_cast<
T
*
>
(
LListBase::last
());
119
}
120
121
//- Return the last entry
122
const
T
*
last
()
const
123
{
124
return
static_cast<
const
T
*
>
(
LListBase::last
());
125
}
126
127
128
// Edit
129
130
//- Remove and return head
131
T
*
removeHead
()
132
{
133
return
static_cast<
T
*
>
(
LListBase::removeHead
());
134
}
135
136
//- Remove and return element
137
T
*
remove
(
T
*
p
)
138
{
139
return
static_cast<
T
*
>
(
LListBase::remove
(
p
));
140
}
141
142
//- Remove and return specified by iterator
143
T
*
remove
(
iterator
& it)
144
{
145
return
static_cast<
T
*
>
(
LListBase::remove
(it));
146
}
147
148
149
// Member operators
150
151
void
operator=
(
const
UILList<LListBase, T>
&);
152
153
154
// STL type definitions
155
156
//- Type of values the DLList contains.
157
typedef
T
value_type
;
158
159
//- Type that can be used for storing into DLList::value_type
160
// objects.
161
typedef
T
&
reference
;
162
163
//- Type that can be used for storing into constant
164
// DLList::value_type objects.
165
typedef
const
T
&
const_reference
;
166
167
//- The type that can represent the size of a DLList.
168
typedef
label
size_type
;
169
170
171
// STL iterator
172
173
typedef
typename
LListBase::iterator
LListBase_iterator
;
174
175
//- An STL-conforming iterator
176
class
iterator
177
:
178
public
LListBase_iterator
179
{
180
181
public
:
182
183
//- Construct from base iterator
184
iterator
185
(
186
LListBase_iterator
baseIter
187
)
188
:
189
LListBase_iterator
(baseIter)
190
{}
191
192
193
// Member operators
194
195
T
&
operator*
()
196
{
197
return
static_cast<
T
&
>
(
LListBase_iterator::operator*
());
198
}
199
200
T
&
operator()
()
201
{
202
return
operator*
();
203
}
204
205
iterator
&
operator++
()
206
{
207
LListBase_iterator::operator++
();
208
return
*
this
;
209
}
210
};
211
212
213
// STL const_iterator
214
215
typedef
typename
LListBase::const_iterator
LListBase_const_iterator
;
216
217
//- An STL-conforming const_iterator
218
class
const_iterator
219
:
220
public
LListBase_const_iterator
221
{
222
223
public
:
224
225
//- Construct from base const_iterator
226
const_iterator
227
(
228
LListBase_const_iterator
baseIter
229
)
230
:
231
LListBase_const_iterator
(baseIter)
232
{}
233
234
//- Construct from base iterator
235
const_iterator
236
(
237
LListBase_iterator
baseIter
238
)
239
:
240
LListBase_const_iterator
(baseIter)
241
{}
242
243
244
// Member operators
245
246
const
T
&
operator*
()
247
{
248
return
249
static_cast<
const
T
&
>
250
(
LListBase_const_iterator::operator*
());
251
}
252
253
const
T
&
operator()
()
254
{
255
return
operator*
();
256
}
257
258
const_iterator
&
operator++
()
259
{
260
LListBase_const_iterator::operator++
();
261
return
*
this
;
262
}
263
};
264
265
266
// STL member operators
267
268
//- Equality operation on ULists of the same type.
269
// Returns true when the ULists are element-wise equal
270
// (using UList::value_type::operator==). Takes linear time.
271
bool
operator==
(
const
UILList<LListBase, T>
&)
const
;
272
273
//- The opposite of the equality operation. Takes linear time.
274
bool
operator!=
(
const
UILList<LListBase, T>
&)
const
;
275
276
277
// Ostream operator
278
279
friend
Ostream
& operator<< <LListBase, T>
280
(
281
Ostream
&,
282
const
UILList<LListBase, T>
&
283
);
284
};
285
286
287
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288
289
}
// End namespace Foam
290
291
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292
293
#ifdef NoRepository
294
# include "
UILList.C
"
295
#endif
296
297
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298
299
#endif
300
301
// ************************ vim: set sw=4 sts=4 et: ************************ //