bitSet Class Reference

A bitSet stores bits (elements with only two states) in packed internal format and supports a variety of bit-set operations. Its behaviour is largely list-like, with some HashSet features. More...

Inheritance diagram for bitSet:
[legend]
Collaboration diagram for bitSet:
[legend]

Classes

class  const_iterator
 A const_iterator for iterating across on values. More...
 
class  reference
 A reference supporting read/write access to an entry. More...
 

Public Types

typedef unsigned int const_reference
 
- Public Types inherited from PackedList< 1 >
typedef unsigned int block_type
 The storage block type for bit elements. More...
 
typedef unsigned int const_reference
 

Public Member Functions

 ClassName ("bitSet")
 Declare type-name (with debug switch) More...
 
 bitSet () noexcept
 Default construct an empty, zero-sized set. More...
 
 bitSet (Istream &is)
 Construct from Istream. More...
 
 bitSet (const label n)
 Construct with given size, with all bits set to 0. More...
 
 bitSet (const label n, const bool val)
 Construct with given size and value for all elements. More...
 
 bitSet (const bitSet &bitset)
 Copy construct. More...
 
 bitSet (bitSet &&bitset)
 Move construct. More...
 
 bitSet (const bitSet &bitset, const labelUList &addr)
 Copy construct a subset. More...
 
template<class Addr >
 bitSet (const bitSet &bitset, const IndirectListBase< label, Addr > &addr)
 Copy construct a subset. More...
 
 bitSet (const bitSet &bitset, const labelRange &range)
 Copy construct a subset range. More...
 
 bitSet (const UList< bool > &bools)
 Construct from a list of bools. More...
 
 bitSet (const label n, const labelUList &locations)
 
template<class Addr >
 bitSet (const label n, const IndirectListBase< label, Addr > &locations)
 
template<unsigned N>
 bitSet (const label n, const FixedList< label, N > &locations)
 
 bitSet (const label n, std::initializer_list< label > locations)
 
 bitSet (const labelUList &locations)
 
template<class Addr >
 bitSet (const IndirectListBase< label, Addr > &locations)
 
template<unsigned N>
 bitSet (const FixedList< label, N > &locations)
 
autoPtr< bitSetclone () const
 Clone. More...
 
bool all () const
 True if all bits in this bitset are set or if the set is empty. More...
 
bool any () const
 True if any bits in this bitset are set. More...
 
bool none () const
 True if no bits in this bitset are set. More...
 
bool uniform () const
 True if all entries have identical values, and the set is non-empty. More...
 
unsigned int count (const bool on=true) const
 Count number of bits set. More...
 
bool intersects (const bitSet &other) const
 True if any bits in the other bitset intersect (are the same). More...
 
bool test (const label pos) const
 Test value at specified position, never auto-vivify entries. More...
 
bool found (const label pos) const
 Test value at specified position, never auto-vivify entries. More...
 
label find_first () const
 Locate the first bit that is set. More...
 
label find_first_not () const
 Locate the first bit that is unset. More...
 
label find_last () const
 Locate the last bit set. More...
 
label find_next (label pos) const
 Locate the next bit set, starting one beyond the specified position. More...
 
labelList toc () const
 The indices of the on bits as a sorted labelList. More...
 
labelList sortedToc () const
 The indices of the on bits as a sorted labelList. More...
 
List< boolvalues () const
 Return the bitset values as a boolList. More...
 
void fill (const bool val)
 Assign all entries to the given value. More...
 
void assign (const UList< bool > &bools)
 Copy assign all entries from a list of bools. More...
 
void set (const bitSet &bitset)
 Set specified bits from another bitset. More...
 
void set (const labelRange &range)
 Set the specified range of bits. More...
 
bitSetunset (const bitSet &other)
 
void unset (const labelRange &range)
 Unset the specified range of bits specified, never auto-vivifies. More...
 
void flip ()
 Invert all bits in the addressable region. More...
 
void flip (const label pos)
 Invert bits at the specified position. More...
 
void swap (bitSet &bitset)
 Swap contents. More...
 
void transfer (bitSet &bitset)
 
bitSetbound (const label maxSize)
 Ensure the addressable range does not exceed maxSize. More...
 
bitSetbound (const bitSet &other)
 Ensure the addressable range does not exceed that of other. More...
 
bitSetextend (const label minSize)
 Ensure that minSize is covered by the bitSet. More...
 
bitSetextend (const bitSet &other)
 Ensure the bitset is addressable throughout the range of other. More...
 
template<class InputIter >
label setMany (InputIter first, InputIter last)
 Set the locations listed by the iterator range,. More...
 
label set (const labelUList &locations)
 Set the listed locations to true. More...
 
template<class Addr >
label set (const IndirectListBase< label, Addr > &locations)
 Set the listed locations to true. More...
 
template<unsigned N>
label set (const FixedList< label, N > &locations)
 Set the listed locations to true. More...
 
template<class InputIter >
label unset (InputIter first, InputIter last)
 
label unset (const labelUList &locations)
 Unset the listed locations, never auto-vivifies. More...
 
template<class Addr >
label unset (const IndirectListBase< label, Addr > &locations)
 Unset the listed locations, never auto-vivifies. More...
 
template<unsigned N>
label unset (const FixedList< label, N > &locations)
 Unset the listed locations, never auto-vivifies. More...
 
const_iterator begin () const
 Iterator set to the position of the first on bit. More...
 
const_iterator cbegin () const
 Iterator set to the position of the first on bit. More...
 
const_iterator begin (label pos) const
 
const_iterator cbegin (label pos) const
 
const_iterator end () const noexcept
 Iterator beyond the end of the bitSet. More...
 
const_iterator cend () const noexcept
 Iterator beyond the end of the bitSet. More...
 
bool operator() (const label pos) const
 Test value at specified position, same as test() More...
 
unsigned int operator[] (const label i) const
 Identical to get() - get value at index. More...
 
reference operator[] (const label i)
 Non-const access to value at index. More...
 
bitSetoperator= (const bitSet &bitset)
 Copy assignment. More...
 
bitSetoperator= (bitSet &&bitset)
 Move assignment. More...
 
bitSetoperator= (const bool val)
 Assign all entries to the given value. fill() More...
 
bitSetoperator&= (const bitSet &other)
 Bitwise-AND all the bits in other with the bits in this bitset. More...
 
bitSetoperator|= (const bitSet &other)
 Bitwise-OR operator - similar to the set() method. More...
 
bitSetoperator^= (const bitSet &other)
 Bitwise-XOR operator - retains unique entries. More...
 
bitSetoperator-= (const bitSet &other)
 Remove entries from this list - identical to the unset() method. More...
 
InfoProxy< bitSetinfo () const
 Return info proxy. More...
 
void assign (const unsigned int val)
 Deprecated(2020-11) use fill() More...
 
template<class Addr>
Foam::label set (const IndirectListBase< label, Addr > &locations)
 
template<class Addr>
Foam::label unset (const IndirectListBase< label, Addr > &locations)
 
template<class InputIter >
Foam::label setMany (InputIter first, InputIter last)
 
template<class InputIter>
Foam::label unset (InputIter first, InputIter last)
 
template<unsigned N>
Foam::label set (const FixedList< label, N > &locations)
 
template<unsigned N>
Foam::label unset (const FixedList< label, N > &locations)
 
- Public Member Functions inherited from PackedList< 1 >
void writeEntry (const word &keyword, Ostream &os) const
 Write as a dictionary entry with keyword. More...
 
constexpr PackedList () noexcept
 Default construct, zero-sized and no allocation. More...
 
 PackedList (const label numElem)
 Construct for given number of elements, initializes values to 0. More...
 
 PackedList (const label numElem, const unsigned int val)
 
 PackedList (Istream &is)
 Construct from Istream. More...
 
 PackedList (const PackedList< Width > &list)
 Copy construct. More...
 
 PackedList (PackedList< Width > &&list)
 Move construct. More...
 
 PackedList (const PackedList< Width > &list, const labelUList &addr)
 Copy construct a subset. More...
 
 PackedList (const PackedList< Width > &list, const IndirectListBase< label, Addr > &addr)
 Copy construct a subset. More...
 
 PackedList (const PackedList< Width > &list, const labelRange &range)
 Copy construct a subset range. More...
 
 PackedList (const labelUList &values)
 Construct from a list of values. More...
 
 PackedList (const IndirectListBase< label, Addr > &values)
 Construct from a indirect list of values. More...
 
autoPtr< PackedList< Width > > clone () const
 Clone. More...
 
void checkIndex (const label i) const
 Check index is within valid range [0,size) More...
 
label size () const noexcept
 Number of entries. More...
 
bool empty () const noexcept
 True if the list is empty (ie, size() is zero). More...
 
label capacity () const noexcept
 The number of elements that can be stored with reallocating. More...
 
bool uniform () const
 True if all entries have identical values, and list is non-empty. More...
 
bool equal (const PackedList< Width > &other) const
 Test for equality of sizes and the bits set. More...
 
unsigned int get (const label i) const
 Get value at index i or 0 for out-of-range. More...
 
bool set (const label i, unsigned int val=~0u)
 Set value at index i, default value set is the max_value. More...
 
bool unset (const label i)
 Unset the entry at index i. More...
 
labelList values () const
 Return the values as a list of labels. More...
 
List< IntType > unpack () const
 Return the values as a list of integral type. More...
 
List< IntType > unpack (const labelRange &range) const
 Return the range of values as a list of integral type. More...
 
List< IntType > unpack (const labelUList &locations) const
 
Foam::List< IntType > unpack () const
 
Foam::List< IntType > unpack (const labelRange &range) const
 
Foam::List< IntType > unpack (const labelUList &locations) const
 
void fill (const unsigned int val)
 Assign all entries to the given value. More...
 
bool trim (label minpos=-1)
 
void reset ()
 Clear all bits but do not adjust the addressable size. More...
 
void setCapacity (const label numElem)
 Alter the size of the underlying storage. More...
 
void resize (const label numElem, const unsigned int val=0u)
 Reset addressable list size, does not shrink the allocated size. More...
 
void resize_nocopy (const label numElem)
 Currently identical to resize. Subject to future change (Oct-2021) More...
 
void reserve (const label numElem)
 Reserve allocation space for at least this size. More...
 
void clear ()
 Clear the list, i.e. set addressable size to zero. More...
 
void clearStorage ()
 Clear the list and delete storage. More...
 
void shrink ()
 Shrink the allocated space to what is actually used. More...
 
void swap (PackedList< Width > &rhs)
 Swap contents with argument. More...
 
void transfer (PackedList< Width > &rhs)
 
label nBlocks () const
 The number of internal storage blocks. More...
 
const List< unsigned int > & storage () const
 Return the underlying storage blocks. More...
 
List< unsigned int > & storage ()
 Return the underlying storage blocks. More...
 
const unsigned int * cdata () const noexcept
 A const pointer to the raw storage. More...
 
unsigned int * data () noexcept
 A pointer to the raw storage. More...
 
const char * cdata_bytes () const noexcept
 A const pointer to the raw storage, reinterpreted as byte data. More...
 
char * data_bytes () noexcept
 A pointer to the raw storage, reinterpreted as byte data. More...
 
std::streamsize size_bytes () const noexcept
 
std::streamsize byteSize () const noexcept
 
OstreamprintBits (Ostream &os, bool debugOutput=false) const
 Print bit patterns, optionally with extra debug. More...
 
IstreamreadList (Istream &is)
 Clear list and read from stream. More...
 
OstreamwriteList (Ostream &os, const label shortLen=0) const
 Write List, with line-breaks in ASCII when length exceeds shortLen. More...
 
PackedList< Width > & append (const unsigned int val)
 Append a value at the end of the list. More...
 
unsigned int remove ()
 Remove and return the last element. More...
 
unsigned int operator[] (const label i) const
 Identical to get() - get value at index. More...
 
reference operator[] (const label i)
 Non-const access to value at index. More...
 
void operator= (const PackedList< Width > &lst)
 Copy assignment. More...
 
void operator= (PackedList< Width > &&lst)
 Move assignment. More...
 
void operator= (const unsigned int val)
 Assign all entries to the given value. fill() More...
 
InfoProxy< PackedList< Width > > info () const
 Return info proxy. More...
 
void assign (const unsigned int val)
 Deprecated(2020-11) use fill() More...
 
void assign (const PackedList< Width > &rhs)
 Deprecated(2020-11) use operator=. More...
 
void setSize (const label n, unsigned int val=0u)
 Alias for resize() More...
 

Static Public Member Functions

static const bitSetnull ()
 Return a null bitSet reference. More...
 
- Static Public Member Functions inherited from PackedList< 1 >
static constexpr label num_blocks (label numElem) noexcept
 
static constexpr block_type mask_lower (unsigned elementOffset)
 Masking for all bits below the element offset. More...
 

Protected Member Functions

bitSetminusEq (const bitSet &other)
 The set difference. More...
 
bitSetandEq (const bitSet &other)
 The set logical AND. More...
 
bitSetorEq (const bitSet &other, const bool strict=true)
 The set logical OR. More...
 
bitSetxorEq (const bitSet &other, const bool strict=true)
 The set logical XOR. More...
 
- Protected Member Functions inherited from PackedList< 1 >
unsigned int repeated_value (unsigned val)
 
unsigned int readValue (Istream &is)
 
void setPair (Istream &is)
 Read an index/value pair and set accordingly. More...
 
void setPair (Istream &is)
 
void writeEntry (Ostream &os) const
 Write as a dictionary entry. More...
 
void clear_trailing_bits ()
 Clear any partial rubbish in the last addressable block. More...
 
void copyAssign (const PackedList< Width > &rhs)
 Copy assignment. More...
 

Additional Inherited Members

- Static Public Attributes inherited from PackedList< 1 >
static constexpr unsigned bits_per_block
 The number of bits in a single block. More...
 
static constexpr unsigned element_width
 The width of an individual element (in bits). More...
 
static constexpr unsigned elem_per_block
 The number of elements stored per data block. More...
 
static constexpr block_type max_value
 
- Protected Types inherited from PackedList< 1 >
typedef List< block_typeblock_container
 The internal container for storing the blocks. More...
 
- Static Protected Member Functions inherited from PackedList< 1 >
static unsigned int repeated_value (unsigned val)
 A fill value for complete blocks. More...
 
static unsigned int readValue (Istream &is)
 Read a list entry (allows for specialization) More...
 
- Protected Attributes inherited from PackedList< 1 >
block_container blocks_
 The blocks of raw data. More...
 
label size_
 Number of entries used. More...
 

Detailed Description

A bitSet stores bits (elements with only two states) in packed internal format and supports a variety of bit-set operations. Its behaviour is largely list-like, with some HashSet features.

Source files
See also
Foam::BitOps Foam::PackedList

Definition at line 63 of file bitSet.H.

Member Typedef Documentation

◆ const_reference

typedef unsigned int const_reference

Definition at line 122 of file bitSet.H.

Constructor & Destructor Documentation

◆ bitSet() [1/17]

bitSet ( )
inlinenoexcept

Default construct an empty, zero-sized set.

Definition at line 77 of file bitSetI.H.

◆ bitSet() [2/17]

bitSet ( Istream is)
explicit

Construct from Istream.

Definition at line 290 of file bitSet.C.

◆ bitSet() [3/17]

bitSet ( const label  n)
inlineexplicit

Construct with given size, with all bits set to 0.

Definition at line 83 of file bitSetI.H.

◆ bitSet() [4/17]

bitSet ( const label  n,
const bool  val 
)
inline

Construct with given size and value for all elements.

Definition at line 89 of file bitSetI.H.

References bitSet::fill().

Here is the call graph for this function:

◆ bitSet() [5/17]

bitSet ( const bitSet bitset)
inline

Copy construct.

Definition at line 97 of file bitSetI.H.

◆ bitSet() [6/17]

bitSet ( bitSet &&  bitset)
inline

Move construct.

Definition at line 103 of file bitSetI.H.

◆ bitSet() [7/17]

bitSet ( const bitSet bitset,
const labelUList addr 
)

Copy construct a subset.

Definition at line 298 of file bitSet.C.

References Foam::HashSetOps::bitset(), PackedList< Width >::get(), bitSet::set(), and UList< T >::size().

Here is the call graph for this function:

◆ bitSet() [8/17]

bitSet ( const bitSet bitset,
const IndirectListBase< label, Addr > &  addr 
)

Copy construct a subset.

Definition at line 55 of file bitSetTemplates.C.

References Foam::HashSetOps::bitset(), PackedList< Width >::get(), Foam::BitOps::set(), and IndirectListBase< T, Addr >::size().

Here is the call graph for this function:

◆ bitSet() [9/17]

bitSet ( const bitSet bitset,
const labelRange range 
)

Copy construct a subset range.

Definition at line 311 of file bitSet.C.

References Foam::HashSetOps::bitset(), PackedList< Width >::get(), Foam::pos(), range, and bitSet::set().

Here is the call graph for this function:

◆ bitSet() [10/17]

bitSet ( const UList< bool > &  bools)
inlineexplicit

Construct from a list of bools.

Definition at line 109 of file bitSetI.H.

References bitSet::assign(), and Foam::HashSetOps::bools().

Here is the call graph for this function:

◆ bitSet() [11/17]

bitSet ( const label  n,
const labelUList locations 
)
inline

Construct with given size with all bits set to 0, subsequently add specified locations as 1.

Definition at line 117 of file bitSetI.H.

References UList< T >::begin(), UList< T >::end(), and bitSet::setMany().

Here is the call graph for this function:

◆ bitSet() [12/17]

bitSet ( const label  n,
const IndirectListBase< label, Addr > &  locations 
)
inline

Construct with given size with all bits set to 0, subsequently add specified locations as 1.

Definition at line 127 of file bitSetI.H.

References IndirectListBase< T, Addr >::begin(), and IndirectListBase< T, Addr >::end().

Here is the call graph for this function:

◆ bitSet() [13/17]

bitSet ( const label  n,
const FixedList< label, N > &  locations 
)

Construct with given size with all bits set to 0, subsequently add specified locations as 1.

Definition at line 34 of file bitSetTemplates.C.

References FixedList< T, N >::begin(), FixedList< T, N >::end(), and bitSet::setMany().

Here is the call graph for this function:

◆ bitSet() [14/17]

bitSet ( const label  n,
std::initializer_list< label >  locations 
)
inline

Construct with given size with all bits set to 0, subsequently add specified locations as 1.

Definition at line 139 of file bitSetI.H.

◆ bitSet() [15/17]

bitSet ( const labelUList locations)
inlineexplicit

Construct with automatic sizing (filled with 0), and populate with specified locations as 1.

Definition at line 150 of file bitSetI.H.

References UList< T >::begin(), UList< T >::end(), and bitSet::setMany().

Here is the call graph for this function:

◆ bitSet() [16/17]

bitSet ( const IndirectListBase< label, Addr > &  locations)
inlineexplicit

Construct with automatic sizing (filled with 0), and populate with specified locations as 1.

Definition at line 160 of file bitSetI.H.

References IndirectListBase< T, Addr >::begin(), and IndirectListBase< T, Addr >::end().

Here is the call graph for this function:

◆ bitSet() [17/17]

bitSet ( const FixedList< label, N > &  locations)
explicit

Construct with automatic sizing (filled with 0), and populate with specified locations as 1.

Definition at line 44 of file bitSetTemplates.C.

References FixedList< T, N >::begin(), FixedList< T, N >::end(), and bitSet::setMany().

Here is the call graph for this function:

Member Function Documentation

◆ minusEq()

Foam::bitSet & minusEq ( const bitSet other)
protected

The set difference.

A = (A - B)
A = (A & !B)
A = (A & ~B)

A and B can have different sizes. Does not change the original set size.

Definition at line 42 of file bitSet.C.

References PackedList< Width >::blocks_, PackedList< 1 >::blocks_, Foam::expressions::patchExpr::debug, PackedList< 1 >::empty(), PackedList< Width >::empty(), InfoInFunction, Foam::min(), Foam::nl, PackedList< 1 >::num_blocks(), PackedList< 1 >::reset(), PackedList< Width >::size(), and PackedList< 1 >::size().

Referenced by bitSet::operator-=(), and bitSet::unset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ andEq()

Foam::bitSet & andEq ( const bitSet other)
protected

The set logical AND.

A = (A & B)

A and B can have different sizes.. Does not change the original set size.

Definition at line 77 of file bitSet.C.

References PackedList< Width >::blocks_, Foam::expressions::patchExpr::debug, PackedList< Width >::empty(), InfoInFunction, Foam::min(), Foam::nl, reset(), and PackedList< Width >::size().

Referenced by bitSet::operator&=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ orEq()

Foam::bitSet & orEq ( const bitSet other,
const bool  strict = true 
)
protected

The set logical OR.

A = (A | B)

A and B can have different sizes

Note
The default (strict=true) ignores additional length from B, whereas (strict=false) permits the set to automatically grow to accommodate additional elements arising from B.

Definition at line 118 of file bitSet.C.

References PackedList< Width >::blocks_, Foam::expressions::patchExpr::debug, PackedList< Width >::empty(), InfoInFunction, Foam::min(), Foam::nl, resize(), PackedList< Width >::size(), and Foam::stringOps::trim().

Referenced by bitSet::operator|=(), and bitSet::set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xorEq()

Foam::bitSet & xorEq ( const bitSet other,
const bool  strict = true 
)
protected

The set logical XOR.

A = (A ^ B)

A and B can have different sizes. Sizing behaviour as per orEq.

Definition at line 205 of file bitSet.C.

References PackedList< Width >::blocks_, Foam::expressions::patchExpr::debug, PackedList< Width >::empty(), InfoInFunction, Foam::min(), Foam::nl, reset(), resize(), PackedList< Width >::size(), and Foam::stringOps::trim().

Referenced by bitSet::operator^=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ null()

const Foam::bitSet & null ( )
inlinestatic

Return a null bitSet reference.

Definition at line 454 of file bitSetI.H.

◆ ClassName()

ClassName ( "bitSet"  )

Declare type-name (with debug switch)

◆ clone()

Foam::autoPtr< Foam::bitSet > clone ( ) const
inline

Clone.

Definition at line 170 of file bitSetI.H.

References autoPtr< T >::New().

Here is the call graph for this function:

◆ all()

bool all ( ) const
inline

True if all bits in this bitset are set or if the set is empty.

Returning true for an empty set may not seem intuitive, but conforms to how boost has defined things.

Note
Method name compatibility with boost::dynamic_bitset

Definition at line 460 of file bitSetI.H.

References PackedList< 1 >::empty().

Referenced by triSurface::checkTriangles(), NASedgeFormat::read(), STARCDedgeFormat::read(), and bitSet::uniform().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ any()

bool any ( ) const
inline

True if any bits in this bitset are set.

Note
Method name compatibility with boost::dynamic_bitset

Definition at line 468 of file bitSetI.H.

References PackedList< 1 >::blocks_, PackedList< 1 >::num_blocks(), and PackedList< 1 >::size().

Referenced by ensightMesh::correct(), bitSet::none(), Foam::HashSetOps::used(), and inverseDistance::walkFront().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ none()

bool none ( ) const
inline

True if no bits in this bitset are set.

Note
Method name compatibility with boost::dynamic_bitset

Definition at line 487 of file bitSetI.H.

References bitSet::any().

Referenced by ensightMesh::correct(), distanceSurface::createGeometry(), and bitSet::uniform().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uniform()

bool uniform ( ) const
inline

True if all entries have identical values, and the set is non-empty.

Definition at line 493 of file bitSetI.H.

References bitSet::all(), bitSet::none(), PackedList< 1 >::size(), and bitSet::test().

Here is the call graph for this function:

◆ count()

unsigned int count ( const bool  on = true) const
inline

Count number of bits set.

Parameters
oncan be set to false to count the number of unset bits instead.
Note
Method name compatibility with boost::dynamic_bitset

Definition at line 499 of file bitSetI.H.

References Foam::BitOps::bit_count(), PackedList< 1 >::blocks_, PackedList< 1 >::num_blocks(), and PackedList< 1 >::size().

Referenced by Foam::inplaceSubset(), isoSurfaceCell::isoSurfaceCell(), isoSurfaceTopo::isoSurfaceTopo(), dynamicRefineFvMesh::mapFields(), Foam::operator<<(), meshRefinement::printMeshInfo(), dynamicRefineFvMesh::selectRefineCells(), dynamicRefineFvMesh::selectUnrefinePoints(), faceAreaWeightAMI::setNextFaces(), meshRefinement::updateIntersections(), Foam::HashSetOps::used(), and triSurface::writeStats().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ intersects()

bool intersects ( const bitSet other) const

True if any bits in the other bitset intersect (are the same).

Note
Method name compatibility with boost::dynamic_bitset

Definition at line 348 of file bitSet.C.

References PackedList< Width >::blocks_, Foam::min(), and PackedList< Width >::size().

Here is the call graph for this function:

◆ test()

bool test ( const label  pos) const
inline

Test value at specified position, never auto-vivify entries.

Note
Method name compatibility with std::bitset

Definition at line 520 of file bitSetI.H.

References PackedList< 1 >::get(), and Foam::pos().

Referenced by extendedEdgeMesh::autoMap(), Foam::calcNormalDistance_filtered(), dynamicRefineFvMesh::calculateProtectedCells(), primitiveMeshTools::cellDeterminant(), dynamicRefineFvMesh::checkEightAnchorPoints(), ensightFaces::classify(), ensightMesh::correct(), meshRefinement::countHits(), snappyLayerDriver::doLayers(), dynamicRefineFvMesh::extendMarkedCells(), distanceSurface::filterKeepLargestRegion(), distanceSurface::filterKeepNearestRegions(), distanceSurface::filterPrepareRegionSplit(), meshRefinement::gAverage(), dynamicRefineFvMesh::init(), isoSurfaceTopo::isoSurfaceTopo(), bitSet::operator()(), distanceSurface::refineBlockedCells(), dynamicRefineFvMesh::selectRefineCells(), dynamicRefineFvMesh::selectUnrefinePoints(), fvMeshSubset::setCellSubset(), lumpedPointMovement::setInterpolator(), faceAreaWeightAMI::setNextFaces(), fieldSmoother::smoothLambdaMuDisplacement(), extendedEdgeMesh::sortPointsAndEdges(), triSurface::subsetMesh(), bitSet::uniform(), meshRefinement::updateIntersections(), inverseDistance::walkFront(), meshRefinement::weightedSum(), and meshRefinement::zonify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ found()

bool found ( const label  pos) const
inline

Test value at specified position, never auto-vivify entries.

Note
Method name compatibility with HashSet

Definition at line 526 of file bitSetI.H.

References PackedList< 1 >::get(), and Foam::pos().

Here is the call graph for this function:

◆ find_first()

Foam::label find_first ( ) const
inline

Locate the first bit that is set.

Returns
the location or -1 if there are no bits set.
Note
Method name compatibility with boost::dynamic_bitset

Definition at line 314 of file bitSetI.H.

References PackedList< 1 >::blocks_, PackedList< 1 >::elem_per_block, PackedList< 1 >::num_blocks(), Foam::pos(), and PackedList< 1 >::size().

Referenced by Foam::ListOps::setValue(), and Foam::HashSetOps::used().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_first_not()

Foam::label find_first_not ( ) const
inline

Locate the first bit that is unset.

Returns
the location or -1 if the set is empty or all bits are on.
Note
Provided for symmetry with find_first()

Definition at line 342 of file bitSetI.H.

References PackedList< 1 >::blocks_, PackedList< 1 >::elem_per_block, and Foam::pos().

Here is the call graph for this function:

◆ find_last()

Foam::label find_last ( ) const
inline

Locate the last bit set.

Returns
the location or -1 if there are no bits set.
Note
Provided for symmetry with find_first()

Definition at line 374 of file bitSetI.H.

References PackedList< 1 >::blocks_, PackedList< 1 >::elem_per_block, PackedList< 1 >::num_blocks(), Foam::pos(), and PackedList< 1 >::size().

Referenced by topoBitSet::check(), writerCaching::latestGeomIndex(), and topoBitSet::updateLabels().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_next()

Foam::label find_next ( label  pos) const
inline

Locate the next bit set, starting one beyond the specified position.

Returns
the location or -1 if there are no further bits set.
Note
Method name compatibility with boost::dynamic_bitset

Definition at line 400 of file bitSetI.H.

References PackedList< 1 >::blocks_, PackedList< 1 >::elem_per_block, PackedList< 1 >::num_blocks(), Foam::pos(), and PackedList< 1 >::size().

Referenced by faceAreaWeightAMI::setNextFaces(), Foam::ListOps::setValue(), and Foam::HashSetOps::used().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toc()

Foam::labelList toc ( ) const

The indices of the on bits as a sorted labelList.

Note
Method name compatibility with HashSet

Definition at line 527 of file bitSet.C.

References Foam::BitOps::any(), Foam::BitOps::count(), Foam::output(), and Foam::pos().

Referenced by snappySnapDriver::calcNearestSurface(), snappySnapDriver::detectNearSurfaces(), and bitSet::sortedToc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sortedToc()

Foam::labelList sortedToc ( ) const
inline

The indices of the on bits as a sorted labelList.

This is identical to toc(), which is always sorted.

Note
Method name compatibility with HashSet

Definition at line 532 of file bitSetI.H.

References bitSet::toc().

Referenced by faMesh::boundaryPoints(), dynamicMultiMotionSolverFvMesh::init(), faMesh::internalPoints(), and fvMeshSubset::setCellSubset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ values()

Foam::List< bool > values ( ) const

Return the bitset values as a boolList.

When the output is a bool, this is more efficient than unpack()

Definition at line 566 of file bitSet.C.

References Foam::output(), and Foam::pos().

Referenced by faceBitSet::distribute(), and pointBitSet::distribute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill()

void fill ( const bool  val)
inline

Assign all entries to the given value.

Definition at line 550 of file bitSetI.H.

References PackedList< 1 >::blocks_, PackedList< 1 >::clear_trailing_bits(), PackedList< 1 >::empty(), PackedList< 1 >::num_blocks(), and PackedList< 1 >::size().

Referenced by bitSet::bitSet(), and bitSet::operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ assign() [1/2]

void assign ( const UList< bool > &  bools)

Copy assign all entries from a list of bools.

Definition at line 328 of file bitSet.C.

References Foam::HashSetOps::bools(), clear(), resize(), and Foam::BitOps::set().

Referenced by bitSet::bitSet(), pointBitSet::distribute(), and faceBitSet::distribute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set() [1/7]

void set ( const bitSet bitset)
inline

Set specified bits from another bitset.

The current set size may grow to accommodate any new bits (auto-vivifies).

Definition at line 574 of file bitSetI.H.

References Foam::HashSetOps::bitset(), and bitSet::orEq().

Referenced by AABBTree< Type >::AABBTree(), geometric::add(), Foam::apply(), extendedEdgeMesh::autoMap(), bitSet::bitSet(), dynamicRefineFvMesh::calculateProtectedCells(), dynamicOversetFvMesh::cellAverage(), cuttingSurfaceBase::cellSelection(), dynamicRefineFvMesh::checkEightAnchorPoints(), edgeCollapser::checkMeshQuality(), ABAQUSCore::readHelper::compact_nodes(), fvMeshSubsetProxy::correct(), ensightMesh::correct(), dynamicRefineFvMesh::extendMarkedCells(), distanceSurface::filterKeepLargestRegion(), distanceSurface::filterKeepNearestRegions(), meshRefinement::getMasterEdges(), isoSurfaceBase::ignoreCyclics(), dynamicMultiMotionSolverFvMesh::init(), dynamicRefineFvMesh::init(), isoSurfaceCell::isoSurfaceCell(), isoSurfaceTopo::isoSurfaceTopo(), dynamicRefineFvMesh::mapFields(), meshRefinement::markOutsideFaces(), Foam::markupBoundaryPoints(), PatchTools::matchEdges(), dynamicOversetFvMesh::normalisation(), bitSet::reference::operator=(), cuttingSurfaceBase::performCut(), NASedgeFormat::read(), STARCDedgeFormat::read(), dynamicRefineFvMesh::refine(), distanceSurface::refineBlockedCells(), sampledPatch::sampleOnPoints(), sampledFaceZone::sampleOnPoints(), inverseDistance::seedCell(), ZoneMesh< cellZone, polyMesh >::selection(), dynamicRefineFvMesh::selectRefineCandidates(), dynamicRefineFvMesh::selectUnrefinePoints(), Foam::BitOps::set(), lumpedPointMovement::setInterpolator(), Foam::simpleGeometricFilter(), triSurface::subsetMesh(), MeshedSurface< Foam::face >::subsetMesh(), dynamicRefineFvMesh::unrefine(), rawTopoChangerFvMesh::update(), topoBitSet::updateLabels(), inverseDistance::walkFront(), writeObjects::write(), and triSurface::writeStats().

Here is the call graph for this function:

◆ set() [2/7]

void set ( const labelRange range)

Set the specified range of bits.

The current set size may grow to accommodate any new bits (auto-vivifies).

Note
this operation is generally more efficient than calling set(pos) on individual bits.

Definition at line 368 of file bitSet.C.

References labelRange::adjust(), labelRange::after(), IntRange< IntType >::empty(), IntRange< IntType >::first(), range, resize(), and IntRange< IntType >::start().

Here is the call graph for this function:

◆ unset() [1/9]

Foam::bitSet & unset ( const bitSet other)
inline

Unset (subtract) the bits specified in the other bitset, which is a set difference corresponds to the logical operation

A = (A & !B)

The result is comparable to 'operator-='

A and B can have different sizes. Does not change the original set size.

Definition at line 612 of file bitSetI.H.

References bitSet::minusEq().

Referenced by Foam::apply(), faceAreaWeightAMI::calcAddressing(), triSurface::checkTriangles(), Foam::BitOps::unset(), and bitSet::unset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unset() [2/9]

void unset ( const labelRange range)

Unset the specified range of bits specified, never auto-vivifies.

Note
this operation can be more efficient than calling unset(pos) on individual bits.

Definition at line 446 of file bitSet.C.

References labelRange::after(), IntRange< IntType >::empty(), IntRange< IntType >::first(), range, resize(), and IntRange< IntType >::start().

Here is the call graph for this function:

◆ flip() [1/2]

void flip ( )
inline

Invert all bits in the addressable region.

Definition at line 618 of file bitSetI.H.

References PackedList< 1 >::blocks_, PackedList< 1 >::clear_trailing_bits(), PackedList< 1 >::num_blocks(), and PackedList< 1 >::size().

Referenced by ensightMesh::correct(), faMesh::internalPoints(), Foam::operator~(), and Foam::simpleGeometricFilter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flip() [2/2]

void flip ( const label  pos)
inline

Invert bits at the specified position.

A no-op if the position is out-of-range

Definition at line 633 of file bitSetI.H.

References bitSet::reference::flip(), and PackedList< 1 >::size().

Here is the call graph for this function:

◆ swap()

void swap ( bitSet bitset)
inline

Swap contents.

Definition at line 538 of file bitSetI.H.

References Foam::HashSetOps::bitset(), and PackedList< Width >::swap().

Here is the call graph for this function:

◆ transfer()

void transfer ( bitSet bitset)
inline

Transfer the contents of the argument list into this list and annul the argument list.

Definition at line 544 of file bitSetI.H.

References Foam::HashSetOps::bitset(), and PackedList< Width >::transfer().

Referenced by fvMeshSubsetProxy::correct(), bitSet::operator=(), and inverseDistance::walkFront().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bound() [1/2]

Foam::bitSet & bound ( const label  maxSize)
inline

Ensure the addressable range does not exceed maxSize.

Either decreases the size of the bitSet or is a no-op.

pointField& pts = mesh.points();
bitset.bound(pts.size());
for (const label pointi : bitset)
{
pts[pointi] ...
}

Definition at line 642 of file bitSetI.H.

References PackedList< 1 >::resize(), and PackedList< 1 >::size().

Referenced by bitSet::bound().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bound() [2/2]

Foam::bitSet & bound ( const bitSet other)
inline

Ensure the addressable range does not exceed that of other.

Either decreases the size of the bitSet or is a no-op.

Definition at line 653 of file bitSetI.H.

References bitSet::bound(), and PackedList< Width >::size().

Here is the call graph for this function:

◆ extend() [1/2]

Foam::bitSet & extend ( const label  minSize)
inline

Ensure that minSize is covered by the bitSet.

Either increases the size of the bitSet or is a no-op.

Definition at line 659 of file bitSetI.H.

References PackedList< 1 >::resize(), and PackedList< 1 >::size().

Referenced by bitSet::extend().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extend() [2/2]

Foam::bitSet & extend ( const bitSet other)
inline

Ensure the bitset is addressable throughout the range of other.

Either increases the size of the bitSet or is a no-op.

Definition at line 670 of file bitSetI.H.

References bitSet::extend(), and PackedList< Width >::size().

Here is the call graph for this function:

◆ setMany() [1/2]

label setMany ( InputIter  first,
InputIter  last 
)

Set the locations listed by the iterator range,.

auto-vivify entries if needed.

Returns
number of locations changed

Referenced by bitSet::bitSet(), and bitSet::set().

Here is the caller graph for this function:

◆ set() [3/7]

Foam::label set ( const labelUList locations)
inline

Set the listed locations to true.

Does auto-vivify for non-existent entries.

Returns
number of locations changed

Definition at line 580 of file bitSetI.H.

References UList< T >::begin(), UList< T >::end(), and bitSet::setMany().

Here is the call graph for this function:

◆ set() [4/7]

label set ( const IndirectListBase< label, Addr > &  locations)
inline

Set the listed locations to true.

Does auto-vivify for non-existent entries.

Returns
number of locations changed

◆ set() [5/7]

label set ( const FixedList< label, N > &  locations)

Set the listed locations to true.

Does auto-vivify for non-existent entries.

Returns
number of locations changed

◆ unset() [3/9]

label unset ( InputIter  first,
InputIter  last 
)

Unset the locations listed by the iterator range, never auto-vivify entries.

Returns
number of locations changed

◆ unset() [4/9]

Foam::label unset ( const labelUList locations)
inline

Unset the listed locations, never auto-vivifies.

Returns
number of locations changed

Definition at line 596 of file bitSetI.H.

References UList< T >::begin(), UList< T >::end(), and bitSet::unset().

Here is the call graph for this function:

◆ unset() [5/9]

label unset ( const IndirectListBase< label, Addr > &  locations)
inline

Unset the listed locations, never auto-vivifies.

Returns
number of locations changed

◆ unset() [6/9]

label unset ( const FixedList< label, N > &  locations)

Unset the listed locations, never auto-vivifies.

Returns
number of locations changed

◆ begin() [1/2]

Foam::bitSet::const_iterator begin ( ) const
inline

Iterator set to the position of the first on bit.

Definition at line 278 of file bitSetI.H.

◆ cbegin() [1/2]

Foam::bitSet::const_iterator cbegin ( ) const
inline

Iterator set to the position of the first on bit.

Definition at line 284 of file bitSetI.H.

◆ begin() [2/2]

Foam::bitSet::const_iterator begin ( label  pos) const
inline

Iterator set to the position of the first on bit that occurs at or beyond the given position

Definition at line 290 of file bitSetI.H.

References Foam::pos().

Here is the call graph for this function:

◆ cbegin() [2/2]

Foam::bitSet::const_iterator cbegin ( label  pos) const
inline

Iterator set to the position of the first on bit that occurs at or beyond the given position

Definition at line 296 of file bitSetI.H.

References Foam::pos().

Here is the call graph for this function:

◆ end()

Foam::bitSet::const_iterator end ( ) const
inlinenoexcept

Iterator beyond the end of the bitSet.

Definition at line 302 of file bitSetI.H.

◆ cend()

Foam::bitSet::const_iterator cend ( ) const
inlinenoexcept

Iterator beyond the end of the bitSet.

Definition at line 308 of file bitSetI.H.

◆ operator()()

bool operator() ( const label  pos) const
inline

Test value at specified position, same as test()

Enables use as a predicate

Definition at line 678 of file bitSetI.H.

References Foam::pos(), and bitSet::test().

Here is the call graph for this function:

◆ operator[]() [1/2]

unsigned int operator[] ( const label  i) const
inline

Identical to get() - get value at index.

Never auto-vivify entries.

Definition at line 684 of file bitSetI.H.

References PackedList< 1 >::get().

Here is the call graph for this function:

◆ operator[]() [2/2]

Foam::bitSet::reference operator[] ( const label  i)
inline

Non-const access to value at index.

Fatal for out-of-range indices

Definition at line 690 of file bitSetI.H.

References PackedList< 1 >::checkIndex().

Here is the call graph for this function:

◆ operator=() [1/3]

Foam::bitSet & operator= ( const bitSet bitset)
inline

Copy assignment.

Definition at line 699 of file bitSetI.H.

References Foam::HashSetOps::bitset(), and PackedList< Width >::operator=().

Here is the call graph for this function:

◆ operator=() [2/3]

Foam::bitSet & operator= ( bitSet &&  bitset)
inline

Move assignment.

Definition at line 706 of file bitSetI.H.

References Foam::HashSetOps::bitset(), and bitSet::transfer().

Here is the call graph for this function:

◆ operator=() [3/3]

Foam::bitSet & operator= ( const bool  val)
inline

Assign all entries to the given value. fill()

Definition at line 713 of file bitSetI.H.

References bitSet::fill().

Here is the call graph for this function:

◆ operator&=()

Foam::bitSet & operator&= ( const bitSet other)
inline

Bitwise-AND all the bits in other with the bits in this bitset.

The operands may have dissimilar sizes without affecting the size of the set.

Definition at line 720 of file bitSetI.H.

References bitSet::andEq().

Here is the call graph for this function:

◆ operator|=()

Foam::bitSet & operator|= ( const bitSet other)
inline

Bitwise-OR operator - similar to the set() method.

The operands may have dissimilar sizes without affecting the size of the set.

Definition at line 726 of file bitSetI.H.

References bitSet::orEq().

Here is the call graph for this function:

◆ operator^=()

Foam::bitSet & operator^= ( const bitSet other)
inline

Bitwise-XOR operator - retains unique entries.

The operands may have dissimilar sizes without affecting the size of the set.

Definition at line 732 of file bitSetI.H.

References bitSet::xorEq().

Here is the call graph for this function:

◆ operator-=()

Foam::bitSet & operator-= ( const bitSet other)
inline

Remove entries from this list - identical to the unset() method.

The operands may have dissimilar sizes without affecting the size of the set.

Definition at line 738 of file bitSetI.H.

References bitSet::minusEq().

Here is the call graph for this function:

◆ info()

InfoProxy<bitSet> info ( ) const
inline

Return info proxy.

Definition at line 582 of file bitSet.H.

◆ assign() [2/2]

void assign ( const unsigned int  val)
inline

Deprecated(2020-11) use fill()

Deprecated:
(2020-11) use fill()

Definition at line 592 of file bitSet.H.

◆ set() [6/7]

Foam::label set ( const IndirectListBase< label, Addr > &  locations)
inline

Definition at line 588 of file bitSetI.H.

References IndirectListBase< T, Addr >::begin(), IndirectListBase< T, Addr >::end(), and bitSet::setMany().

Here is the call graph for this function:

◆ unset() [7/9]

Foam::label unset ( const IndirectListBase< label, Addr > &  locations)
inline

Definition at line 604 of file bitSetI.H.

References IndirectListBase< T, Addr >::begin(), IndirectListBase< T, Addr >::end(), and bitSet::unset().

Here is the call graph for this function:

◆ setMany() [2/2]

Foam::label setMany ( InputIter  first,
InputIter  last 
)

Definition at line 75 of file bitSetTemplates.C.

References Foam::max(), and Foam::BitOps::set().

Here is the call graph for this function:

◆ unset() [8/9]

Foam::label unset ( InputIter  first,
InputIter  last 
)

Definition at line 101 of file bitSetTemplates.C.

References Foam::BitOps::unset().

Here is the call graph for this function:

◆ set() [7/7]

Foam::label set ( const FixedList< label, N > &  locations)

Definition at line 118 of file bitSetTemplates.C.

References FixedList< T, N >::begin(), and FixedList< T, N >::end().

Here is the call graph for this function:

◆ unset() [9/9]

Foam::label unset ( const FixedList< label, N > &  locations)

Definition at line 125 of file bitSetTemplates.C.

References FixedList< T, N >::begin(), FixedList< T, N >::end(), and Foam::BitOps::unset().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::bitSet::bound
bitSet & bound(const label maxSize)
Ensure the addressable range does not exceed maxSize.
Definition: bitSetI.H:642
B
static const Foam::dimensionedScalar B("", Foam::dimless, 18.678)
A
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
Foam::HashSetOps::bitset
bitSet bitset(const labelHashSet &locations)
Transform the on locations to a bitSet.
Definition: HashOps.C:72
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6