PackedBoolListI.H 5.71 KB
Newer Older
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
5
    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
6
     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

inline Foam::PackedBoolList::PackedBoolList(const label size)
:
    PackedList<1>(size)
{}


inline Foam::PackedBoolList::PackedBoolList
(
    const label size,
    const bool val
)
:
    PackedList<1>(size, (val ? 1u : 0u))
{}


inline Foam::PackedBoolList::PackedBoolList(const PackedBoolList& lst)
:
    PackedList<1>(lst)
{}


inline Foam::PackedBoolList::PackedBoolList(const PackedList<1>& lst)
:
    PackedList<1>(lst)
{}


56
inline Foam::PackedBoolList::PackedBoolList(PackedBoolList&& lst)
57
58
59
:
    PackedList<1>()
{
60
    transfer(lst);
61
62
63
}


64
inline Foam::PackedBoolList::PackedBoolList(PackedList<1>&& lst)
65
:
66
67
68
69
    PackedList<1>()
{
    transfer(lst);
}
70
71


72
inline Foam::PackedBoolList::PackedBoolList(const UList<bool>& lst)
73
:
74
    PackedList<1>(lst.size())
75
{
76
77
78
79
80
81
82
83
84
85
    // Set according to indices that are true
    const label len = lst.size();

    for (label i = 0; i < len; ++i)
    {
        if (lst[i])
        {
            this->set(i, 1u);
        }
    }
86
87
88
}


89
inline Foam::PackedBoolList::PackedBoolList(const labelUList& indices)
90
:
91
92
93
94
    PackedBoolList(indices.size(), indices)
{}


95
inline Foam::PackedBoolList::PackedBoolList(const labelUIndList& indices)
96
97
98
99
100
101
102
103
104
105
106
107
:
    PackedBoolList(indices.size(), indices)
{}


inline Foam::PackedBoolList::PackedBoolList
(
    const label size,
    const labelUList& indices
)
:
    PackedList<1>(size)
108
109
110
111
112
{
    set(indices);
}


113
114
115
inline Foam::PackedBoolList::PackedBoolList
(
    const label size,
116
    const labelUIndList& indices
117
)
118
:
119
    PackedList<1>(size)
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
{
    set(indices);
}


inline Foam::autoPtr<Foam::PackedBoolList>
Foam::PackedBoolList::clone() const
{
    return autoPtr<PackedBoolList>(new PackedBoolList(*this));
}


// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

inline void Foam::PackedBoolList::transfer(PackedBoolList& lst)
{
    PackedList<1>::transfer(static_cast<PackedList<1>&>(lst));
}


inline void Foam::PackedBoolList::transfer(PackedList<1>& lst)
{
    PackedList<1>::transfer(lst);
}


// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //

148
inline void Foam::PackedBoolList::operator=(const bool val)
149
150
151
152
153
{
    PackedList<1>::operator=(val);
}


154
inline void Foam::PackedBoolList::operator=(const PackedBoolList& lst)
155
156
157
158
159
{
    PackedList<1>::operator=(lst);
}


160
inline void Foam::PackedBoolList::operator=(const PackedList<1>& lst)
161
162
163
164
165
{
    PackedList<1>::operator=(lst);
}


166
167
168
169
170
171
172
173
174
175
176
177
inline void Foam::PackedBoolList::operator=(PackedBoolList&& lst)
{
    transfer(lst);
}


inline void Foam::PackedBoolList::operator=(PackedList<1>&& lst)
{
    transfer(lst);
}


178
inline void Foam::PackedBoolList::operator=(const labelUList& indices)
179
180
181
182
183
184
{
    clear();
    set(indices);
}


185
inline void Foam::PackedBoolList::operator=(const labelUIndList& indices)
186
187
188
189
190
191
{
    clear();
    set(indices);
}


192
193
194
195
196
197
198
199
200
201
inline Foam::PackedBoolList
Foam::PackedBoolList::operator~() const
{
    PackedBoolList result(*this);
    result.flip();

    return result;
}


202
203
204
205
206
207
208
209
210
inline Foam::PackedBoolList&
Foam::PackedBoolList::operator&=(const PackedList<1>& lst)
{
    subset(lst);
    return *this;
}


inline Foam::PackedBoolList&
211
Foam::PackedBoolList::operator&=(const labelUList& indices)
212
213
214
215
216
217
218
{
    subset(indices);
    return *this;
}


inline Foam::PackedBoolList&
219
Foam::PackedBoolList::operator&=(const labelUIndList& indices)
220
221
222
223
224
225
226
227
228
229
230
231
232
233
{
    subset(indices);
    return *this;
}


inline Foam::PackedBoolList&
Foam::PackedBoolList::operator|=(const PackedList<1>& lst)
{
    set(lst);
    return *this;
}


234
inline Foam::PackedBoolList&
235
Foam::PackedBoolList::operator|=(const labelUList& indices)
236
237
238
239
240
241
242
{
    set(indices);
    return *this;
}


inline Foam::PackedBoolList&
243
Foam::PackedBoolList::operator|=(const labelUIndList& indices)
244
245
246
247
248
249
250
251
252
{
    set(indices);
    return *this;
}


inline Foam::PackedBoolList&
Foam::PackedBoolList::operator+=(const PackedList<1>& lst)
{
253
    return operator|=(lst);
254
255
256
257
}


inline Foam::PackedBoolList&
258
Foam::PackedBoolList::operator+=(const labelUList& indices)
259
{
260
    return operator|=(indices);
261
262
263
264
}


inline Foam::PackedBoolList&
265
Foam::PackedBoolList::operator+=(const labelUIndList& indices)
266
{
267
268
269
270
271
272
273
274
275
    return operator|=(indices);
}


inline Foam::PackedBoolList&
Foam::PackedBoolList::operator-=(const PackedList<1>& lst)
{
    unset(lst);
    return *this;
276
277
278
279
}


inline Foam::PackedBoolList&
280
Foam::PackedBoolList::operator-=(const labelUList& indices)
281
282
283
284
285
286
287
{
    unset(indices);
    return *this;
}


inline Foam::PackedBoolList&
288
Foam::PackedBoolList::operator-=(const labelUIndList& indices)
289
290
291
292
293
294
295
{
    unset(indices);
    return *this;
}


// ************************************************************************* //