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
Lists
List
List.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::List
26
27
Description
28
A 1D array of objects of type <T>, where the size of the vector
29
is known and used for subscript bounds checking, etc.
30
31
Storage is allocated on free-store during construction.
32
33
SourceFiles
34
List.C
35
ListI.H
36
ListIO.C
37
38
\*---------------------------------------------------------------------------*/
39
40
#ifndef List_H
41
#define List_H
42
43
#include <
OpenFOAM/UList.H
>
44
#include <
OpenFOAM/autoPtr.H
>
45
#include <
OpenFOAM/Xfer.H
>
46
47
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49
namespace
Foam
50
{
51
52
class
Istream;
53
class
Ostream;
54
55
// Forward declaration of friend functions and operators
56
57
template
<
class
T>
class
List;
58
59
template
<
class
T> Istream&
operator>>
(Istream&, List<T>&);
60
61
template
<
class
T,
unsigned
Size>
class
FixedList;
62
template
<
class
T>
class
PtrList;
63
template
<
class
T>
class
SLList;
64
template
<
class
T,
unsigned
SizeInc,
unsigned
SizeMult,
unsigned
SizeDiv>
65
class
DynamicList;
66
template
<
class
T>
class
SortableList;
67
template
<
class
T>
class
IndirectList;
68
template
<
class
T>
class
UIndirectList;
69
template
<
class
T>
class
BiIndirectList
;
70
71
typedef
UList<label>
unallocLabelList
;
72
73
/*---------------------------------------------------------------------------*\
74
Class List Declaration
75
\*---------------------------------------------------------------------------*/
76
77
template
<
class
T>
78
class
List
79
:
80
public
UList
<T>
81
{
82
83
protected
:
84
85
//- Override size to be inconsistent with allocated storage.
86
// Use with care.
87
inline
void
size
(
const
label);
88
89
public
:
90
91
// Static Member Functions
92
93
//- Return a null List
94
inline
static
const
List<T>
&
null
();
95
96
// Constructors
97
98
//- Null constructor.
99
inline
List
();
100
101
//- Construct with given size.
102
explicit
List
(
const
label);
103
104
//- Construct with given size and value for all elements.
105
List
(
const
label,
const
T
&);
106
107
//- Copy constructor.
108
List
(
const
List<T>
&);
109
110
//- Construct by transferring the parameter contents
111
List
(
const
Xfer
<
List<T>
>&);
112
113
//- Construct as copy or re-use as specified.
114
List
(
List<T>
&,
bool
reUse);
115
116
//- Construct as subset.
117
List
(
const
UList<T>
&,
const
unallocLabelList
& mapAddressing);
118
119
//- Construct given start and end iterators.
120
template
<
class
InputIterator>
121
List
(InputIterator first, InputIterator last);
122
123
//- Construct as copy of FixedList<T, Size>
124
template
<
unsigned
Size>
125
List
(
const
FixedList<T, Size>
&);
126
127
//- Construct as copy of PtrList<T>
128
List
(
const
PtrList<T>
&);
129
130
//- Construct as copy of SLList<T>
131
List
(
const
SLList<T>
&);
132
133
//- Construct as copy of IndirectList<T>
134
List
(
const
IndirectList<T>
&);
135
136
//- Construct as copy of UIndirectList<T>
137
List
(
const
UIndirectList<T>
&);
138
139
//- Construct as copy of BiIndirectList<T>
140
List
(
const
BiIndirectList<T>
&);
141
142
//- Construct from Istream.
143
List
(
Istream
&);
144
145
//- Clone
146
inline
autoPtr<List<T>
>
clone
()
const
;
147
148
149
// Destructor
150
151
~List
();
152
153
154
// Related types
155
156
//- Declare type of subList
157
typedef
SubList<T>
subList
;
158
159
160
// Member Functions
161
162
//- Return the number of elements in the UList.
163
inline
label
size
()
const
;
164
165
166
// Edit
167
168
//- Reset size of List.
169
inline
void
resize
(
const
label);
170
171
//- Reset size of List and value for new elements.
172
inline
void
resize
(
const
label,
const
T
&);
173
174
//- Reset size of List.
175
void
setSize
(
const
label);
176
177
//- Reset size of List and value for new elements.
178
void
setSize
(
const
label,
const
T
&);
179
180
//- Clear the list, i.e. set size to zero.
181
void
clear
();
182
183
//- Append a List at the end of this list
184
inline
void
append
(
const
UList<T>
&);
185
186
//- Append a UIndirectList at the end of this list
187
inline
void
append
(
const
UIndirectList<T>
&);
188
189
//- Transfer the contents of the argument List into this list
190
// and annull the argument list.
191
void
transfer
(
List<T>
&);
192
193
//- Transfer the contents of the argument List into this list
194
// and annull the argument list.
195
template
<
unsigned
SizeInc,
unsigned
SizeMult,
unsigned
SizeDiv>
196
void
transfer
(
DynamicList<T, SizeInc, SizeMult, SizeDiv>
&);
197
198
//- Transfer the contents of the argument List into this list
199
// and annull the argument list.
200
void
transfer
(
SortableList<T>
&);
201
202
//- Transfer contents to the Xfer container
203
inline
Xfer< List<T>
>
xfer
();
204
205
//- Return subscript-checked element of UList.
206
inline
T
&
newElmt
(
const
label);
207
208
// Member operators
209
210
//- Assignment from UList operator. Takes linear time.
211
void
operator=
(
const
UList<T>
&);
212
213
//- Assignment operator. Takes linear time.
214
void
operator=
(
const
List<T>
&);
215
216
//- Assignment from SLList operator. Takes linear time.
217
void
operator=
(
const
SLList<T>
&);
218
219
//- Assignment from IndirectList operator. Takes linear time.
220
void
operator=
(
const
IndirectList<T>
&);
221
222
//- Assignment from UIndirectList operator. Takes linear time.
223
void
operator=
(
const
UIndirectList<T>
&);
224
225
//- Assignment from BiIndirectList operator. Takes linear time.
226
void
operator=
(
const
BiIndirectList<T>
&);
227
228
//- Assignment of all entries to the given value
229
inline
void
operator=
(
const
T
&);
230
231
232
// Istream operator
233
234
//- Read List from Istream, discarding contents of existing List.
235
friend
Istream
&
operator
>> <
T
>
236
(
Istream
&,
List<T>
&);
237
};
238
239
240
//- Read a bracket-delimited list, or handle a single value as list of size 1.
241
// For example,
242
// @code
243
// wList = readList<word>(IStringStream("(patch1 patch2 patch3)")());
244
// wList = readList<word>(IStringStream("patch0")());
245
// @endcode
246
// Mostly useful for handling command-line arguments.
247
template
<
class
T>
248
List<T>
readList
(
Istream
&);
249
250
251
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252
253
}
// End namespace Foam
254
255
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256
257
# include <
OpenFOAM/ListI.H
>
258
259
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260
261
#ifdef NoRepository
262
# include <
OpenFOAM/List.C
>
263
#endif
264
265
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266
267
#endif
268
269
// ************************ vim: set sw=4 sts=4 et: ************************ //