Loading...
Searching...
No Matches
boolVectorI.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2020-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31:
32 FixedList<bool, 3>(false)
33{}
34
36inline Foam::boolVector::boolVector(const bool val)
37:
38 FixedList<bool, 3>(val)
39{}
40
41
43(
44 const bool vx,
45 const bool vy,
46 const bool vz
47)
49 x() = vx;
50 y() = vy;
51 z() = vz;
52}
53
54
57 FixedList<bool, 3>(is)
58{}
59
60
61// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63inline bool Foam::boolVector::all() const noexcept
64{
65 return (x() && y() && z());
66}
67
69inline bool Foam::boolVector::any() const noexcept
70{
71 return (x() || y() || z());
72}
73
75inline bool Foam::boolVector::none() const noexcept
76{
77 return !any();
78}
79
80
81inline unsigned int Foam::boolVector::count(const bool on) const
82{
83 unsigned int total = 0;
84
85 for (const bool val : *this)
86 {
87 if (val) ++total;
88 }
89
90 if (!on)
91 {
92 // Return the number of bits that are OFF.
93 return (3u - total);
94 }
95
96 return total;
97}
98
99
100inline void Foam::boolVector::flip()
101{
102 x() = !x();
103 y() = !y();
104 z() = !z();
105}
106
107
108// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
109
110inline void Foam::boolVector::operator=(const bool value)
111{
113}
114
115
116// ************************************************************************* //
scalar y
void operator=(const UList< T > &list)
Assignment to UList operator. Takes linear time.
Definition FixedListI.H:419
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
unsigned int count(const bool on=true) const
Count number of items set.
Definition boolVectorI.H:74
bool none() const noexcept
True if no components are set.
Definition boolVectorI.H:68
void flip()
Invert all values.
Definition boolVectorI.H:93
bool z() const noexcept
The z component.
Definition boolVector.H:194
boolVector & operator=(const boolVector &)=default
Copy assignment.
bool any() const noexcept
True if any components are set.
Definition boolVectorI.H:62
boolVector()
Default construct, zero-initialized (ie, false).
Definition boolVectorI.H:23
bool all() const noexcept
True if all components are set.
Definition boolVectorI.H:56
const direction noexcept
Definition scalarImpl.H:265