Go to the documentation of this file.
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.
empty())
105 const label nblocks = num_blocks(
std::min(size(), other.
size()));
106 const auto& rhs = other.
blocks_;
108 for (label blocki = 0; blocki < nblocks; ++blocki)
110 blocks_[blocki] &= rhs[blocki];
127 <<
"Perform |= on self: ignore" <<
nl;
132 else if (other.
empty())
134 if ((
debug & 2) && !empty())
138 <<
"Perform |= using empty operand: ignore" <<
nl;
149 <<
"Perform |= on empty bitSet" <<
nl;
158 else if ((
debug & 2) && (size() != other.
size()))
161 <<
"Perform |= on dissimilar sized bitSets: "
162 << size() <<
" vs. " << other.
size() <<
nl;
167 if ((size() < other.
size()) && !strict)
181 const label nblocks = num_blocks(
std::min(size(), other.
size()));
182 const auto& rhs = other.
blocks_;
184 for (label blocki = 0; blocki < nblocks; ++blocki)
186 blocks_[blocki] |= rhs[blocki];
198 clear_trailing_bits();
214 <<
"Perform ^= on self: clears all bits" <<
nl;
220 else if (other.
empty())
222 if ((
debug & 2) && !empty())
226 <<
"Perform ^= using empty operand: ignore" <<
nl;
237 <<
"Perform ^= on empty bitSet" <<
nl;
246 else if ((
debug & 2) && (size() != other.
size()))
249 <<
"Perform ^= on dissimilar sized bitSets: "
250 << size() <<
" vs. " << other.
size() <<
nl;
255 if ((size() < other.
size()) && !strict)
264 const label nblocks = num_blocks(
std::min(size(), other.
size()));
265 const auto& rhs = other.
blocks_;
267 for (label blocki = 0; blocki < nblocks; ++blocki)
269 blocks_[blocki] ^= rhs[blocki];
281 clear_trailing_bits();
302 const label len = addr.
size();
304 for (label i = 0; i < len; ++i)
316 const label len =
range.size();
318 for (label i = 0; i < len; ++i)
330 const label len =
bools.size();
338 for (label i = 0; i < len; ++i)
350 if (size() && other.
size())
352 const label nblocks = num_blocks(
std::min(size(), other.
size()));
353 const auto& rhs = other.
blocks_;
355 for (label blocki = 0; blocki < nblocks; ++blocki)
357 if (
bool(blocks_[blocki] & rhs[blocki]))
385 if (slice.
after() >= size())
399 unsigned int bblock = slice.
first() / elem_per_block;
400 unsigned int bmask = slice.
first() % elem_per_block;
403 unsigned int eblock = slice.
after() / elem_per_block;
404 unsigned int emask = slice.
after() % elem_per_block;
407 if (bmask) bmask = mask_lower(bmask);
408 if (emask) emask = mask_lower(emask);
410 if (bblock == eblock)
418 blocks_[bblock] |= (emask^bmask);
426 blocks_[bblock] |= (~bmask);
431 for (
unsigned blocki = bblock; blocki < eblock; ++blocki)
433 blocks_[blocki] = (~0u);
440 blocks_[eblock] |= (emask);
461 if (slice.
after() >= size())
464 const label orig = size();
479 unsigned int bblock = slice.
first() / elem_per_block;
480 unsigned int bmask = slice.
first() % elem_per_block;
483 unsigned int eblock = slice.
after() / elem_per_block;
484 unsigned int emask = slice.
after() % elem_per_block;
487 if (bmask) bmask = mask_lower(bmask);
488 if (emask) emask = mask_lower(emask);
490 if (bblock == eblock)
499 blocks_[bblock] &= (~(emask^bmask));
507 blocks_[bblock] &= (bmask);
512 for (
unsigned blocki = bblock; blocki < eblock; ++blocki)
514 blocks_[blocki] = (0u);
521 blocks_[eblock] &= (~emask);
530 const label total =
any() ?
count() : 0;
542 const label nblocks = num_blocks(size());
543 for (label blocki = 0; blocki < nblocks; ++blocki)
545 unsigned int blockval = blocks_[blocki];
549 for (label
pos = (blocki * elem_per_block); blockval; ++
pos)
558 if (nItem == total)
break;
572 const label nblocks = num_blocks(size());
573 for (label blocki = 0; blocki < nblocks; ++blocki)
575 label
pos = (blocki * elem_per_block);
579 unsigned int blockval = blocks_[blocki];
int debug
Static debugging option.
List< label > labelList
A List of labels.
bitSet & andEq(const bitSet &other)
The set logical AND.
void reset()
Clear all bits but do not adjust the addressable size.
#define InfoInFunction
Report an information message using Foam::Info.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
bitSet() noexcept
Default construct an empty, zero-sized set.
List< bool > bools(const labelHashSet &locations)
bitSet & xorEq(const bitSet &other, const bool strict=true)
The set logical XOR.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
bitSet & unset(const bitSet &other)
string trim(const std::string &s)
Return string trimmed of leading and trailing whitespace.
void adjust() noexcept
Adjust the start to avoid negative indices.
void set(const bitSet &bitset)
Set specified bits from another bitset.
bool empty() const noexcept
True if the list is empty (ie, size() is zero).
bitSet bitset(const labelHashSet &locations)
Transform the on locations to a bitSet.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
unsigned int get(const label i) const
Get value at index i or 0 for out-of-range.
label after() const noexcept
The value after the last element in the range.
block_container blocks_
The blocks of raw data.
labelList toc() const
The indices of the on bits as a sorted labelList.
patchWriters resize(patchIds.size())
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A range or interval of labels defined by a start and a size.
bitSet & minusEq(const bitSet &other)
The set difference.
bool any(const UList< bool > &bools)
True if any entries are 'true'.
static constexpr label num_blocks(label numElem)
bitSet & orEq(const bitSet &other, const bool strict=true)
The set logical OR.
label first() const noexcept
The (inclusive) lower value of the range - same as start()
bool intersects(const bitSet &other) const
True if any bits in the other bitset intersect (are the same).
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
bool empty() const noexcept
Is the range empty?
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
label size() const noexcept
Number of entries.
label start() const noexcept
The (inclusive) lower value of the range.
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
void assign(Field< Tout > &result, const Field< T1 > &a, const UnaryOp &op)
Populate a field as the result of a unary operation on an input.
void assign(const bool val)
Assign all entries to the given value.
defineTypeNameAndDebug(combustionModel, 0)
List< bool > values() const
Return the bitset values as a boolList.
dimensionedScalar pos(const dimensionedScalar &ds)