50 <<
"Perform -= on self: clears all bits" <<
nl;
65 const auto& rhs = other.
blocks_;
67 for (label blocki = 0; blocki < nblocks; ++blocki)
69 blocks_[blocki] &= ~rhs[blocki];
86 <<
"Perform &= on self: ignore" <<
nl;
96 else if (other.none())
104 const label origSize(size());
105 const label otherSize(other.size());
107 if (origSize > otherSize)
116 const label nblocks = num_blocks(
std::min(origSize, otherSize));
117 const auto& rhs = other.blocks_;
119 for (label blocki = 0; blocki < nblocks; ++blocki)
121 blocks_[blocki] &= rhs[blocki];
138 <<
"Perform |= on self: ignore" <<
nl;
143 else if (other.none())
151 const label otherMax(other.find_last());
153 if (otherMax >= size())
161 const label nblocks = num_blocks(
std::min(size(), other.size()));
162 const auto& rhs = other.blocks_;
164 for (label blocki = 0; blocki < nblocks; ++blocki)
166 blocks_[blocki] |= rhs[blocki];
183 <<
"Perform ^= on self: clears all bits" <<
nl;
189 else if (other.none())
197 const label otherMax(other.find_last());
199 if (otherMax >= size())
207 const label nblocks = num_blocks(
std::min(size(), other.size()));
208 const auto& rhs = other.blocks_;
210 for (label blocki = 0; blocki < nblocks; ++blocki)
212 blocks_[blocki] ^= rhs[blocki];
234 const label len = addr.
size();
236 for (label i = 0; i < len; ++i)
248 const label len =
range.size();
250 for (label i = 0; i < len; ++i)
284 for (label i = 0; i < len; ++i)
296 if (size() && other.size())
298 const label nblocks = num_blocks(
std::min(size(), other.size()));
299 const auto& rhs = other.blocks_;
301 for (label blocki = 0; blocki < nblocks; ++blocki)
303 if (
bool(blocks_[blocki] & rhs[blocki]))
316 labelRange slice(
range);
331 if (slice.end_value() >= size())
334 resize(slice.begin_value(),
false);
335 resize(slice.end_value(),
true);
346 unsigned int bblock = slice.begin_value() / elem_per_block;
347 unsigned int bmask = slice.begin_value() % elem_per_block;
350 unsigned int eblock = slice.end_value() / elem_per_block;
351 unsigned int emask = slice.end_value() % elem_per_block;
354 if (bmask) bmask = mask_lower(bmask);
355 if (emask) emask = mask_lower(emask);
357 if (bblock == eblock)
365 blocks_[bblock] |= (emask^bmask);
373 blocks_[bblock] |= (~bmask);
378 for (
unsigned blocki = bblock; blocki < eblock; ++blocki)
380 blocks_[blocki] = (~0u);
387 blocks_[eblock] |= (emask);
396 const labelRange slice =
range.subset0(size());
408 if (slice.end_value() >= size())
411 const label orig = size();
413 resize(slice.begin_value(),
false);
426 unsigned int bblock = slice.begin_value() / elem_per_block;
427 unsigned int bmask = slice.begin_value() % elem_per_block;
430 unsigned int eblock = slice.end_value() / elem_per_block;
431 unsigned int emask = slice.end_value() % elem_per_block;
434 if (bmask) bmask = mask_lower(bmask);
435 if (emask) emask = mask_lower(emask);
437 if (bblock == eblock)
446 blocks_[bblock] &= (~(emask^bmask));
454 blocks_[bblock] &= (bmask);
459 for (
unsigned blocki = bblock; blocki < eblock; ++blocki)
461 blocks_[blocki] = (0u);
468 blocks_[eblock] &= (~emask);
477 const label total =
any() ?
count() : 0;
489 const label nblocks = num_blocks(size());
490 for (label blocki = 0; blocki < nblocks; ++blocki)
492 unsigned int blockval = blocks_[blocki];
496 for (label
pos = (blocki * elem_per_block); blockval; ++
pos)
505 if (nItem == total)
break;
515 List<bool>
output(size(),
false);
519 const label nblocks = num_blocks(size());
520 for (label blocki = 0; blocki < nblocks; ++blocki)
522 label
pos = (blocki * elem_per_block);
526 unsigned int blockval = blocks_[blocki];
void size(const label n)
Older name for setAddressableSize.
bitSet & orEq(const bitSet &other)
The set logical OR.
void set(const bitSet &bitset)
Set specified bits from another bitset.
bool any(const UList< bool > &bools)
True if any entries are 'true'.
bool none(const UList< bool > &bools)
True if no entries are 'true'.
patchWriters resize(patchIds.size())
A range or interval of labels defined by a start and a size.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
List< bool > values() const
Return the bitset values as a boolList.
bitSet() noexcept
Default construct an empty, zero-sized bitSet.
bitSet & minusEq(const bitSet &other)
The set difference.
bitSet & xorEq(const bitSet &other)
The set logical XOR.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
dimensionedScalar pos(const dimensionedScalar &ds)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
bitSet & unset(const bitSet &other)
Unset (subtract) the bits specified in the other bitset, which is a set difference corresponds to the...
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
List< bool > bools(const labelHashSet &locations)
Transform the on locations to a boolList, with true for each non-negative location and false for all ...
bitSet & andEq(const bitSet &other)
The set logical AND.
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
labelList toc() const
The indices of the on bits as a sorted labelList.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
triangles reserve(surf.size())
void assign(const UList< bool > &bools)
Copy assign all entries from a list of bools.
bool intersects(const bitSet &other) const
True if any bits in the other bitset intersect (are the same).
static Ostream & output(Ostream &os, const IntRange< T > &range)
block_container blocks_
The blocks of raw data.
static constexpr label num_blocks(label numElem) noexcept
Calculate the number of blocks required to _address_ the requested number of elements.
void reset()
Clear all bits but do not adjust the addressable size.
List< label > labelList
A List of labels.
unsigned int get(const label i) const
Get value at index i or 0 for out-of-range.
bool none() const
True if no bits in this bitset are set.
bitSet bitset(const labelHashSet &locations)
Transform the on locations to a bitSet.
label size() const noexcept
Number of entries.
#define InfoInFunction
Report an information message using Foam::Info.