mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: bitSet::find_first_not() method (issue #751)
- find the position of the first bit off - symmetrical with find_first()
This commit is contained in:
@ -40,12 +40,19 @@ Description
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
inline Ostream& report
|
||||
(
|
||||
const bitSet& bitset,
|
||||
bool showBits = false,
|
||||
bool debugOutput = false
|
||||
)
|
||||
|
||||
inline Ostream& extent(const bitSet& bitset)
|
||||
{
|
||||
Info<< "first: " << bitset.find_first()
|
||||
<< " last: " << bitset.find_last()
|
||||
<< " first_not: " << bitset.find_first_not()
|
||||
<< endl;
|
||||
|
||||
return Info;
|
||||
}
|
||||
|
||||
|
||||
inline Ostream& info(const bitSet& bitset)
|
||||
{
|
||||
Info<< "size=" << bitset.size() << "/" << bitset.capacity()
|
||||
<< " count=" << bitset.count()
|
||||
@ -54,6 +61,32 @@ inline Ostream& report
|
||||
<< " any:" << bitset.any()
|
||||
<< " none:" << bitset.none() << nl;
|
||||
|
||||
return Info;
|
||||
}
|
||||
|
||||
|
||||
inline Ostream& info(const UList<bool>& bools)
|
||||
{
|
||||
Info<< "size=" << bools.size()
|
||||
<< " count=" << BitOps::count(bools)
|
||||
<< " !count=" << BitOps::count(bools, false)
|
||||
<< " all:" << BitOps::all(bools)
|
||||
<< " any:" << BitOps::any(bools)
|
||||
<< " none:" << BitOps::none(bools) << nl;
|
||||
|
||||
return Info;
|
||||
}
|
||||
|
||||
|
||||
inline Ostream& report
|
||||
(
|
||||
const bitSet& bitset,
|
||||
bool showBits = false,
|
||||
bool debugOutput = false
|
||||
)
|
||||
{
|
||||
info(bitset);
|
||||
|
||||
Info<< "values: " << flatOutput(bitset) << nl;
|
||||
if (showBits)
|
||||
{
|
||||
@ -66,14 +99,7 @@ inline Ostream& report
|
||||
|
||||
inline Ostream& report(const UList<bool>& bools)
|
||||
{
|
||||
Info<< "size=" << bools.size()
|
||||
<< " count=" << BitOps::count(bools)
|
||||
<< " !count=" << BitOps::count(bools, false)
|
||||
<< " all:" << BitOps::all(bools)
|
||||
<< " any:" << BitOps::any(bools)
|
||||
<< " none:" << BitOps::none(bools) << nl;
|
||||
|
||||
return Info;
|
||||
return info(bools);
|
||||
}
|
||||
|
||||
|
||||
@ -153,10 +179,7 @@ int main(int argc, char *argv[])
|
||||
compare(list1, "...................1..1..1..1..1");
|
||||
|
||||
report(list1, true);
|
||||
|
||||
|
||||
Info<< "first: " << list1.find_first()
|
||||
<< " last: " << list1.find_last() << endl;
|
||||
extent(list1);
|
||||
|
||||
Info<< "iterate through:";
|
||||
for (const label idx : list1)
|
||||
@ -172,6 +195,21 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nflipped bit pattern\n";
|
||||
report(list2, true);
|
||||
extent(list2);
|
||||
|
||||
Info<< "\nsparse set\n";
|
||||
{
|
||||
bitSet sparse(1000);
|
||||
sparse.set(300);
|
||||
|
||||
info(sparse);
|
||||
extent(sparse);
|
||||
|
||||
sparse.set(0);
|
||||
|
||||
info(sparse);
|
||||
extent(sparse);
|
||||
}
|
||||
|
||||
// set every other on
|
||||
forAll(list2, i)
|
||||
|
||||
Reference in New Issue
Block a user