Go to the documentation of this file.
30 inline Foam::label Foam::bitSet::first_not_block()
const
46 for (label blocki=0; blocki < nblocks; ++blocki)
56 for (label blocki=0; blocki < nblocks-1; ++blocki)
134 setMany(locations.
begin(), locations.
end());
141 std::initializer_list<label> locations
146 setMany(locations.begin(), locations.end());
166 setMany(locations.
begin(), locations.
end());
195 inline void Foam::bitSet::reference::operator=
205 inline void Foam::bitSet::reference::operator=
207 const unsigned int val
214 inline Foam::bitSet::reference::operator
unsigned int ()
const
222 inline Foam::bitSet::const_iterator::const_iterator() noexcept
229 inline Foam::bitSet::const_iterator::const_iterator(
const bitSet* parent)
236 inline Foam::bitSet::const_iterator::const_iterator
255 pos_ = set_->find_next(pos_);
260 inline bool Foam::bitSet::const_iterator::operator==
265 return (iter.pos_ == pos_);
269 inline bool Foam::bitSet::const_iterator::operator!=
274 return (iter.pos_ != pos_);
319 for (label blocki = 0; blocki < nblocks; ++blocki)
325 unsigned int blockval =
blocks_[blocki];
344 const label blocki = first_not_block();
357 unsigned int blockval = ~(
blocks_[blocki]);
380 unsigned int blockval =
blocks_[blocki];
403 if (pos < 0 || pos >=
size())
414 unsigned int blockval = (
blocks_[blocki] >> off);
429 for (++blocki; blocki < nblocks; ++blocki)
435 unsigned int blockval =
blocks_[blocki];
456 return NullObjectRef<bitSet>();
462 if (
empty())
return true;
464 return -1 == first_not_block();
474 for (label blocki=0; blocki < nblocks; ++blocki)
501 unsigned int total = 0;
505 for (label blocki = 0; blocki < nblocks; ++blocki)
513 return (
unsigned(
size()) - total);
560 const unsigned int blockval = (val ? ~0u : 0u);
562 for (label blocki=0; blocki < nblocks; ++blocki)
624 for (label blocki=0; blocki < nblocks; ++blocki)
635 if (i >= 0 && i <
size())
644 if (maxSize <
size())
661 if (
size() < minSize)
757 return (result &=
b);
764 return (result |=
b);
771 return (result ^=
b);
778 return (result -=
b);
bool found(const label pos) const
Test value at specified position, never auto-vivify entries.
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
bitSet & andEq(const bitSet &other)
The set logical AND.
bitSet & operator-=(const bitSet &other)
Remove entries from this list - identical to the unset() method.
unsigned int operator[](const label i) const
Identical to get() - get value at index.
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
iterator end()
Return an iterator at end of list.
const_iterator end() const noexcept
Iterator beyond the end of the bitSet.
label find_first() const
Locate the first bit that is set.
bitSet() noexcept
Default construct an empty, zero-sized set.
List< bool > bools(const labelHashSet &locations)
block_type & ref_
Reference to the block.
bool all() const
True if all bits in this bitset are set or if the set is empty.
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...
iterator end() noexcept
Return an iterator to end traversing the UList.
tmp< GeometricField< Type, fvPatchField, volMesh > > operator&(const fvMatrix< Type > &, const DimensionedField< Type, volMesh > &)
bitSet & bound(const label maxSize)
Ensure the addressable range does not exceed maxSize.
unsigned int bit_count(UIntType x)
Count arbitrary number of bits (of an integral type)
autoPtr< bitSet > clone() const
Clone.
A reference supporting read/write access to an entry.
bitSet & unset(const bitSet &other)
bool any() const
True if any bits in this bitset are set.
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
static const bitSet & null()
Return a null bitSet reference.
const_iterator cend() const noexcept
Iterator beyond the end of the bitSet.
const_iterator & operator++()
Move to the next on position.
void set(const bitSet &bitset)
Set specified bits from another bitset.
label setMany(InputIter first, InputIter last)
Set the locations listed by the iterator range,.
void clear_trailing_bits()
Clear any partial rubbish in the last addressable block.
bool empty() const noexcept
True if the list is empty (ie, size() is zero).
bitSet & operator|=(const bitSet &other)
Bitwise-OR operator - similar to the set() method.
bool test(const label pos) const
Test value at specified position, never auto-vivify entries.
bitSet bitset(const labelHashSet &locations)
Transform the on locations to a bitSet.
label operator*() const noexcept
Return the current on position.
void checkIndex(const label i) const
Check index is within valid range [0,size)
unsigned int count(const bool on=true) const
Count number of bits set.
void swap(PackedList< Width > &rhs)
Swap contents with argument.
unsigned int get(const label i) const
Get value at index i or 0 for out-of-range.
static constexpr block_type mask_lower(unsigned elementOffset)
Masking for all bits below the element offset.
bool operator()(const label pos) const
Test value at specified position, same as test()
void flip()
Flip the bit at the position, no range-checking.
block_container blocks_
The blocks of raw data.
labelList toc() const
The indices of the on bits as a sorted labelList.
const_iterator cbegin() const
Iterator set to the position of the first on bit.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
label find_last() const
Locate the last bit set.
reference(bitSet *parent, const label index)
void fill(const bool val)
Assign all entries to the given value.
A const_iterator for iterating across on values.
label find_first_not() const
Locate the first bit that is unset.
bitSet & operator&=(const bitSet &other)
Bitwise-AND all the bits in other with the bits in this bitset.
void assign(const UList< bool > &bools)
Copy assign all entries from a list of bools.
bitSet & minusEq(const bitSet &other)
The set difference.
const_iterator begin() const
Iterator set to the position of the first on bit.
void flip()
Invert all bits in the addressable region.
bitSet & orEq(const bitSet &other, const bool strict=true)
The set logical OR.
label find_next(label pos) const
Locate the next bit set, starting one beyond the specified position.
void transfer(PackedList< Width > &rhs)
bitSet & operator=(const bitSet &bitset)
Copy assignment.
iterator begin()
Return an iterator at begin of list.
static constexpr block_type max_value
bool none() const
True if no bits in this bitset are set.
bitSet operator~(const bitSet &bitset)
Bitset complement, returns a copy of the bitset with all its bits flipped.
static constexpr unsigned elem_per_block
The number of elements stored per data block.
void swap(bitSet &bitset)
Swap contents.
bitSet & extend(const label minSize)
Ensure that minSize is covered by the bitSet.
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
void operator=(const PackedList< Width > &lst)
Copy assignment.
label size() const noexcept
Number of entries.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bitSet & operator^=(const bitSet &other)
Bitwise-XOR operator - retains unique entries.
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
bitSet operator^(const bitSet &a, const bitSet &b)
Bitwise-XOR of two bitsets to form a unique bit-set.
unsigned shift_
The bit shift to access the given sub-portion.
bitSet operator|(const bitSet &a, const bitSet &b)
Bitwise-OR of two bitsets.
bool uniform() const
True if all entries have identical values, and the set is non-empty.
static constexpr label num_blocks(label numElem) noexcept
labelList sortedToc() const
The indices of the on bits as a sorted labelList.
void transfer(bitSet &bitset)
dimensionedScalar pos(const dimensionedScalar &ds)