Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
180a2848
Commit
180a2848
authored
Apr 26, 2019
by
Mark OLESEN
Committed by
Andrew Heather
Apr 26, 2019
Browse files
ENH: add '==' and '!=' operators for PackedList/bitSet
- also available as equal() member function
parent
e1609d16
Changes
5
Hide whitespace changes
Inline
Side-by-side
applications/test/bitSet1/Test-bitSet1.C
View file @
180a2848
...
...
@@ -76,6 +76,9 @@ int main(int argc, char *argv[])
bitSet
set2b
(
set2
,
labelRange
(
15
,
30
));
Info
<<
"bitSet slice(15,30) :"
;
report
(
set2b
,
true
);
Info
<<
"set1 == set2: "
<<
(
set2
==
set2b
)
<<
nl
;
Info
<<
"set1 != set2: "
<<
(
set2
!=
set2b
)
<<
nl
;
{
FixedList
<
label
,
4
>
locs
({
-
1
,
3
,
4
,
12
});
...
...
src/OpenFOAM/containers/Bits/PackedList/PackedList.C
View file @
180a2848
...
...
@@ -145,6 +145,29 @@ bool Foam::PackedList<Width>::uniform() const
}
template
<
unsigned
Width
>
bool
Foam
::
PackedList
<
Width
>::
equal
(
const
PackedList
<
Width
>&
other
)
const
{
if
(
size
()
!=
other
.
size
())
{
return
false
;
}
const
label
nblocks
=
num_blocks
(
size
());
const
auto
&
rhs
=
other
.
blocks_
;
for
(
label
blocki
=
0
;
blocki
<
nblocks
;
++
blocki
)
{
if
(
blocks_
[
blocki
]
!=
rhs
[
blocki
])
{
return
false
;
}
}
return
true
;
}
template
<
unsigned
Width
>
Foam
::
labelList
Foam
::
PackedList
<
Width
>::
values
()
const
{
...
...
src/OpenFOAM/containers/Bits/PackedList/PackedList.H
View file @
180a2848
...
...
@@ -286,6 +286,9 @@ public:
//- True if all entries have identical values, and list is non-empty
bool
uniform
()
const
;
//- Test for equality of sizes and the bits set
bool
equal
(
const
PackedList
<
Width
>&
other
)
const
;
// Access
...
...
@@ -495,7 +498,7 @@ public:
};
// * * * * * * * * * * * * * * *
IOstream
Operators * * * * * * * * * * * * //
// * * * * * * * * * * * * * * *
Global
Operators * * * * * * * * * * * *
*
//
//- Write List to Ostream, as per UList::writeList() with default length.
// The default short-length is given by Detail::ListPolicy::short_length
...
...
@@ -506,6 +509,15 @@ Ostream& operator<<(Ostream& os, const PackedList<Width>& list)
}
//- Test for equality of sizes and the bits set
template
<
unsigned
Width
>
inline
bool
operator
==
(
const
PackedList
<
Width
>&
a
,
const
PackedList
<
Width
>&
b
);
//- Test for inequality of sizes or the bits set
template
<
unsigned
Width
>
inline
bool
operator
!=
(
const
PackedList
<
Width
>&
a
,
const
PackedList
<
Width
>&
b
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace Foam
...
...
src/OpenFOAM/containers/Bits/PackedList/PackedListI.H
View file @
180a2848
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-201
8
OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-201
9
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
...
...
@@ -744,4 +744,28 @@ inline void Foam::PackedList<Width>::operator=(PackedList<Width>&& rhs)
}
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
template
<
unsigned
Width
>
inline
bool
Foam
::
operator
==
(
const
PackedList
<
Width
>&
a
,
const
PackedList
<
Width
>&
b
)
{
return
a
.
equal
(
b
);
}
template
<
unsigned
Width
>
inline
bool
Foam
::
operator
!=
(
const
PackedList
<
Width
>&
a
,
const
PackedList
<
Width
>&
b
)
{
return
!
a
.
equal
(
b
);
}
// ************************************************************************* //
src/OpenFOAM/containers/Bits/bitSet/bitSet.H
View file @
180a2848
...
...
@@ -120,6 +120,7 @@ protected:
// A and B can have different sizes. Sizing behaviour as per orEq.
bitSet
&
xorEq
(
const
bitSet
&
other
,
const
bool
strict
=
true
);
public:
// Forward declaration of access classes
...
...
@@ -554,7 +555,7 @@ public:
};
//
Global Operators
//
* * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
//- Write bitset to Ostream, as per bitSet::writeList() with default length
//- of 40 items.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment