74 setMany(locations.
begin(), locations.
end());
87 setMany(locations.
begin(), locations.
end());
94 std::initializer_list<label> locations
99 setMany(locations.begin(), locations.end());
107 setMany(locations.
begin(), locations.
end());
119 setMany(locations.
begin(), locations.
end());
143 const unsigned int mask = (
max_value << shift_);
148 inline void Foam::bitSet::reference::operator=
158 inline void Foam::bitSet::reference::operator=
160 const unsigned int val
167 inline Foam::bitSet::reference::operator
unsigned int ()
const 175 inline Foam::bitSet::const_iterator::const_iterator()
noexcept 182 inline Foam::bitSet::const_iterator::const_iterator(
const bitSet* parent)
189 inline Foam::bitSet::const_iterator::const_iterator
208 pos_ = set_->find_next(pos_);
213 inline bool Foam::bitSet::const_iterator::operator==
218 return (iter.pos_ == pos_);
222 inline bool Foam::bitSet::const_iterator::operator!=
227 return (iter.pos_ != pos_);
279 unsigned int blockval =
blocks_[blocki];
311 unsigned int blockval = ~(
blocks_[blocki]);
334 unsigned int blockval =
blocks_[blocki];
357 if (pos < 0 || pos >=
size())
368 unsigned int blockval = (
blocks_[blocki] >> off);
383 for (++blocki; blocki < nblocks; ++blocki)
389 unsigned int blockval =
blocks_[blocki];
410 if (
empty())
return true;
429 unsigned int total = 0;
433 for (label blocki = 0; blocki < nblocks; ++blocki)
441 return (
unsigned(
size()) - total);
491 const unsigned int blockval = (val ? ~0u : 0u);
493 for (label blocki=0; blocki < nblocks; ++blocki)
555 for (label blocki=0; blocki < nblocks; ++blocki)
575 if (maxSize <
size())
592 if (
size() < minSize)
603 return extend(other.size());
690 result.resize_last();
700 result.resize_last();
710 result.resize_last();
720 result.resize_last();
A reference supporting read/write access to an entry.
unsigned int count(const bool on=true) const
Count number of bits set.
const_iterator & operator++()
Move to the next on position.
bitSet & orEq(const bitSet &other)
The set logical OR.
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, auto-vivify entries if needed.
void fill(const bool val)
Assign all entries to the given value.
bitSet operator~(const bitSet &bitset)
Bitset complement, returns a copy of the bitset with all its bits flipped.
label find_last() const
Locate the last bit set.
void flip()
Invert all bits in the addressable region.
reference(bitSet *parent, const label index)
Construct by taking reference of block from within the list and the specified index.
labelList sortedToc() const
The indices of the on bits as a sorted labelList.
label find_first() const
Locate the first bit that is set.
bool operator()(const label pos) const
Test value at specified position, same as test()
bitSet & operator=(const bitSet &bitset)
Copy assignment.
void flip()
Flip the bit at the position, no range-checking.
bitSet & minusEq(const bitSet &other)
The set difference.
label find_next(label pos) const
Locate the next bit set, starting one beyond the specified position.
const_iterator begin() const
Iterator set to the position of the first on bit.
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
bitSet & xorEq(const bitSet &other)
The set logical XOR.
unsigned int operator[](const label i) const
Identical to get() - get value at index.
bitSet operator|(const bitSet &a, const bitSet &b)
Bitwise-OR of two bitsets.
void resize_last()
Resize to include the last on bit only.
label find_first_not() const
Locate the first bit that is unset.
bool any() const
True if any bits in this bitset are set.
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
label first_block() const
Find the first block with a '1' bit.
dimensionedScalar pos(const dimensionedScalar &ds)
autoPtr< bitSet > clone() const
Clone.
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...
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
bitSet & operator^=(const bitSet &other)
Bitwise-XOR operator - retains unique entries.
void clear()
Clear the list, i.e. set addressable size to zero.
bitSet & operator|=(const bitSet &other)
Bitwise-OR operator - similar to the set() method.
void transfer(bitSet &bitset)
Transfer the contents of the argument list into this list and annul the argument list.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Unary negation.
bool test(const label pos) const
Test for True value at specified position, never auto-vivify entries.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
label first_not_block() const
Find the first block with a '0' bit.
const_iterator cend() const noexcept
Iterator beyond the end of the bitSet.
constexpr bitSet() noexcept
Default construct an empty, zero-sized bitSet.
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.
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.
bitSet & operator-=(const bitSet &other)
Remove entries from this list - identical to the unset() method.
void swap(PackedList< Width > &rhs)
Swap contents with argument.
iterator begin()
Return an iterator at begin of list.
labelList toc() const
The indices of the on bits as a sorted labelList.
label operator*() const noexcept
Return the current on position.
static constexpr block_type max_value
The max value for an element which is also the bit-mask of the individual element.
iterator end()
Return an iterator at end of list.
bitSet operator^(const bitSet &a, const bitSet &b)
Bitwise-XOR of two bitsets to form a unique bit-set.
bool empty() const noexcept
True if the list is empty (ie, size() is zero).
A const_iterator for iterating across on values.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
tmp< GeometricField< Type, faPatchField, areaMesh > > operator &(const faMatrix< Type > &, const DimensionedField< Type, areaMesh > &)
unsigned int bit_count(UIntType x)
Count arbitrary number of bits (of an integral type)
const_iterator cbegin() const
Iterator set to the position of the first on bit.
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.
static constexpr unsigned elem_per_block
The number of elements stored per data block.
void clear_trailing_bits()
Clear any partial rubbish in the last addressable block.
iterator end() noexcept
Return an iterator to end traversing the UList.
void transfer(PackedList< Width > &rhs)
Transfer the contents of the argument list into this list and annul the argument list.
const_iterator end() const noexcept
Iterator beyond the end of the bitSet.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
void operator=(const PackedList< Width > &list)
Copy assignment.
void swap(bitSet &bitset)
Swap contents.
bitSet & operator &=(const bitSet &other)
Bitwise-AND all the bits in other with the bits in this bitset.
bitSet & extend(const label minSize)
Ensure that minSize is covered by the bitSet.
bool none() const
True if no bits in this bitset are set.
bitSet bitset(const labelHashSet &locations)
Transform the on locations to a bitSet.
bool all() const
True if all bits in this bitset are set or if the set is empty.
label size() const noexcept
Number of entries.
bitSet & bound(const label maxSize)
Ensure the addressable range does not exceed maxSize.
void checkIndex(const label i) const
Check index is within valid range [0,size)