BaseBitSet< ALLOCATOR > Class Template Reference

#include <basebitset.h>

Detailed Description

template<typename ALLOCATOR = DefaultAllocator>
class maxon::BaseBitSet< ALLOCATOR >

BaseBitSet documentation.

Public Member Functions

 BaseBitSet ()=default
 
 BaseBitSet (BaseBitSet &&rhs)
 
BaseBitSetoperator= (BaseBitSet &&rhs)
 
Bool IsSet (UInt index) const
 
Bool IsSetUnchecked (UInt index) const
 
Result< void > Set (UInt index, Bool &isSet)
 
Bool IsEmpty () const
 
Bool IsPopulated () const
 
Result< void > Set (UInt index)
 
void SetUnchecked (UInt index)
 
void SetRangeUnchecked (UInt first, UInt last)
 
void Clear (UInt index, Bool &cleared)
 
void Clear (UInt index)
 
void Reset ()
 
UInt GetHashCode () const
 
Bool operator== (const BaseBitSet< ALLOCATOR > &rhs) const
 
BaseBitSet< ALLOCATOR > & operator|= (const BaseBitSet< ALLOCATOR > &rhs)
 
BaseBitSet< ALLOCATOR > & operator&= (const BaseBitSet< ALLOCATOR > &rhs)
 
Result< void > CopyFrom (const BaseBitSet< ALLOCATOR > &src)
 
Result< void > Init (UInt count, Bool clearValue)
 
Int CountBits (UInt first=0, UInt last=(UInt) -1) const
 

Private Types

using IntType = UInt
 

Private Member Functions

 MAXON_DISALLOW_COPY_AND_ASSIGN (BaseBitSet)
 
void RemoveTrailingZeroes ()
 
Int CountBitsInWord (IntType word) const
 

Private Attributes

BaseArray< IntType, BASEARRAY_DEFAULT_CHUNK_SIZE, BASEARRAYFLAGS::MOVEANDCOPYOBJECTS, ALLOCATOR > _bits
 

Static Private Attributes

static const UInt INT_WIDTH_EXPONENT
 
static const IntType INT_MASK
 
static const IntType INT_WIDTH
 

Member Typedef Documentation

◆ IntType

using IntType = UInt
private

Constructor & Destructor Documentation

◆ BaseBitSet() [1/2]

BaseBitSet ( )
default

Default constructor.

◆ BaseBitSet() [2/2]

BaseBitSet ( BaseBitSet< ALLOCATOR > &&  rhs)

Move constructor

Parameters
[in]rhsThe bitset which is moved.

Member Function Documentation

◆ MAXON_DISALLOW_COPY_AND_ASSIGN()

MAXON_DISALLOW_COPY_AND_ASSIGN ( BaseBitSet< ALLOCATOR >  )
private

◆ operator=()

BaseBitSet& operator= ( BaseBitSet< ALLOCATOR > &&  rhs)

Move assignment operator

Parameters
[in]rhsThe bitset which is moved.
Returns
A reference to this bitset.

◆ IsSet()

Bool IsSet ( UInt  index) const

Checks if a bit is set in the bitset.

Parameters
[in]indexInput index of the bit which should be set.
Returns
True if the bit at index is set, otherwise false.

◆ IsSetUnchecked()

Bool IsSetUnchecked ( UInt  index) const

Checks if a bit is set in the bitset. It does not check if the underlaying array is big enough to contain a bit at this index.

Parameters
[in]indexInput index of the bit which should be set.
Returns
True if the bit at index is set, otherwise false.

◆ Set() [1/2]

Result<void> Set ( UInt  index,
Bool isSet 
)

Sets the bit at a given index and returns if it was actually set.

Parameters
[in]indexInput index of the bit which should be set.
[out]isSetThis will be set to true if the bit is actually set, otherwise to false.
Returns
OK on success.

◆ IsEmpty()

Bool IsEmpty ( ) const

Check if the bitset is empty.

Returns
True if no bit is set, otherwise false.

◆ IsPopulated()

Bool IsPopulated ( void  ) const

Check if the bitset contains at least one element.

Returns
False if no bit is set, otherwise true.

◆ Set() [2/2]

Result<void> Set ( UInt  index)

Sets the bit at a given index.

Parameters
[in]indexInput index of the bit which should be set.
Returns
OK on success.

◆ SetUnchecked()

void SetUnchecked ( UInt  index)

Sets the bit at a given index. It does not check if the underlaying array is big enough to contain a bit at this index.

Parameters
[in]indexInput index of the bit which should be set.

◆ SetRangeUnchecked()

void SetRangeUnchecked ( UInt  first,
UInt  last 
)

Sets all bits in the given range. first must be smaller or equal to last.

Parameters
[in]firstFirst element to set.
[in]lastLast element to set.

◆ Clear() [1/2]

void Clear ( UInt  index,
Bool cleared 
)

Clears the bit at a given index and returns if it was actually cleared.

Parameters
[in]indexInput index of the bit which should be cleared.
[out]clearedThis will be set to true if the bit is actually cleared, otherwise to false.

◆ Clear() [2/2]

void Clear ( UInt  index)

Clears the bit at a given index.

Parameters
[in]indexInput index of the bit which should be cleared.

◆ Reset()

void Reset ( void  )

Resets the bitset.

◆ GetHashCode()

UInt GetHashCode ( ) const

Gets the hash code for the bitset, using GetHashCode() of the underlaying BaseArray.

Returns
The bitset's hash code.

◆ operator==()

Bool operator== ( const BaseBitSet< ALLOCATOR > &  rhs) const

Compares two bitsets, using the compare operator of the underlaying BaseArray.

Parameters
[in]rhsInput bitset rhs.
Returns
The component-by-component result of this == rhs.

◆ operator|=()

BaseBitSet<ALLOCATOR>& operator|= ( const BaseBitSet< ALLOCATOR > &  rhs)

Calculates the bitwise OR of this bitset and another bitset.

Parameters
[in]rhsInput bitset rhs.
Returns
A reference to this bitset.

◆ operator&=()

BaseBitSet<ALLOCATOR>& operator &= ( const BaseBitSet< ALLOCATOR > &  rhs)

Calculates the bitwise AND of this bitset and another bitset.

Parameters
[in]rhsInput bitset rhs.
Returns
A reference to this bitset.

◆ CopyFrom()

Result<void> CopyFrom ( const BaseBitSet< ALLOCATOR > &  src)

Copies the data from another bitset, using CopyFrom() of the underlaying BaseArray

Parameters
[in]srcSource from which the data is taken
Returns
OK on success.

◆ Init()

Result<void> Init ( UInt  count,
Bool  clearValue 
)

Initializes the array to have at least as much space to contain a certain amount of bits.

Parameters
[in]countNumber of bits.

◆ CountBits()

Int CountBits ( UInt  first = 0,
UInt  last = (UInt)-1 
) const

Counts the bits in the selection

Parameters
[in]firstIndex from which conting starts.
[in]lastIndex where counting ends.
Returns
Number of set bits.

◆ RemoveTrailingZeroes()

void RemoveTrailingZeroes ( )
private

Removes trailing zero bits in the underlaying BaseArray

◆ CountBitsInWord()

Int CountBitsInWord ( IntType  word) const
private

Counts the bits of a word.

Parameters
[in]wordWord in which the bits have to be counted.
Returns
Number of set bits in the word.

Member Data Documentation

◆ INT_WIDTH_EXPONENT

const UInt INT_WIDTH_EXPONENT
staticprivate

◆ INT_MASK

const IntType INT_MASK
staticprivate

◆ INT_WIDTH

const IntType INT_WIDTH
staticprivate

◆ _bits