Open Search
    BaseBitSet< ALLOCATOR, INTTYPE > Class Template Reference

    #include <basebitset.h>

    Detailed Description

    template<typename ALLOCATOR = DefaultAllocator, typename INTTYPE = UInt>
    class maxon::BaseBitSet< ALLOCATOR, INTTYPE >

    BaseBitSet documentation.

    Classes

    class  ResultFunctions
     

    Public Types

    using IntType = INTTYPE
     
    using ConstIterator = BaseBitSetIterator< const BaseBitSet >
     

    Public Member Functions

     BaseBitSet ()=default
     
     BaseBitSet (BaseBitSet &&rhs)
     
    BaseBitSetoperator= (BaseBitSet &&rhs)
     
    Bool IsSet (UInt index) const
     
    MAXON_ATTRIBUTE_FORCE_INLINE Bool IsSetUnchecked (UInt index) const
     
    MAXON_ATTRIBUTE_FORCE_INLINE void ClearUnchecked (UInt index)
     
    Result< void > Set (UInt index, Bool &isSet)
     
    Bool IsEmpty () const
     
    Bool IsPopulated () const
     
    Result< void > SetValue (UInt index, Bool value)
     
    void SetValueUnchecked (UInt index, Bool value)
     
    Result< void > Set (UInt index)
     
    void SetUnchecked (UInt index)
     
    Bool SetAndCheckUnchecked (UInt index)
     
    Result< void > SetRange (UInt first, UInt last)
     
    void SetRangeUnchecked (UInt first, UInt last)
     
    void Clear (UInt index, Bool &cleared)
     
    void Clear (UInt index)
     
    void Reset ()
     
    HashInt GetHashCode () const
     
    Bool operator== (const BaseBitSet< ALLOCATOR, INTTYPE > &rhs) const
     
    BaseBitSet< ALLOCATOR, INTTYPE > & operator|= (const BaseBitSet< ALLOCATOR, INTTYPE > &rhs)
     
    BaseBitSet< ALLOCATOR, INTTYPE > & operator&= (const BaseBitSet< ALLOCATOR, INTTYPE > &rhs)
     
    Result< void > CopyFrom (const BaseBitSet< ALLOCATOR, INTTYPE > &src)
     
    Result< void > MergeOr (const BaseBitSet< ALLOCATOR, INTTYPE > &src)
     
    Result< void > MergeOrNot (const BaseBitSet< ALLOCATOR, INTTYPE > &src)
     
    Result< void > MergeAnd (const BaseBitSet< ALLOCATOR, INTTYPE > &src)
     
    Result< void > MergeAndNot (const BaseBitSet< ALLOCATOR, INTTYPE > &src)
     
    Result< void > MergeXOr (const BaseBitSet< ALLOCATOR, INTTYPE > &src)
     
    void Invert ()
     
    Result< void > Init (UInt count, Bool clearValue)
     
    Int CountBits (UInt first=0, UInt last=(UInt) -1) const
     
    Int GetNextSet (Int index) const
     
    Int GetNextCleared (Int index) const
     
    Int GetCapacity () const
     
    MAXON_ATTRIBUTE_FORCE_INLINE ConstIterator Begin () const
     
    MAXON_ATTRIBUTE_FORCE_INLINE ConstIterator End () const
     
    const Block< const IntType > & GetRawData () const
     

    Static Public Member Functions

    static Result< void > DescribeIO (const DataSerializeInterface &stream)
     
    static Bool IsSet (const Block< const IntType > &raw, Int index)
     

    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 = INTTYPE

    ◆ ConstIterator

    Iterator for read-only access to the bit elements.

    Constructor & Destructor Documentation

    ◆ BaseBitSet() [1/2]

    BaseBitSet ( )
    default

    Default constructor.

    ◆ BaseBitSet() [2/2]

    BaseBitSet ( BaseBitSet< ALLOCATOR, INTTYPE > &&  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, INTTYPE >  )
    private

    ◆ operator=()

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

    Move assignment operator

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

    ◆ IsSet() [1/2]

    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()

    MAXON_ATTRIBUTE_FORCE_INLINE Bool IsSetUnchecked ( UInt  index) const

    Checks if a bit is set in the bitset. It does not check if the underlying 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 index is set, otherwise false.

    ◆ ClearUnchecked()

    MAXON_ATTRIBUTE_FORCE_INLINE void ClearUnchecked ( UInt  index)

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

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

    ◆ 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 ( ) const

    Check if the bitset contains at least one element.

    Returns
    False if no bit is set, otherwise true.

    ◆ SetValue()

    Result<void> SetValue ( UInt  index,
    Bool  value 
    )

    Sets the bit at a given index to the specific value.

    Parameters
    [in]indexInput index of the bit which should be set.
    [in]valueThe value to set the bit to (true or false).
    Returns
    OK on success.

    ◆ SetValueUnchecked()

    void SetValueUnchecked ( UInt  index,
    Bool  value 
    )

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

    Parameters
    [in]indexInput index of the bit which should be set.
    [in]valueThe value to set the bit to (true or false).

    ◆ 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 underlying array is big enough to contain a bit at this index.

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

    ◆ SetAndCheckUnchecked()

    Bool SetAndCheckUnchecked ( UInt  index)

    Sets the bit at a given index. It does not check if the underlying 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 was already set.

    ◆ SetRange()

    Result<void> SetRange ( 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.
    Returns
    OK on success.

    ◆ 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 ( )

    Resets the bitset.

    ◆ GetHashCode()

    HashInt GetHashCode ( ) const

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

    Returns
    The bitset's hash code.

    ◆ operator==()

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

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

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

    ◆ operator|=()

    BaseBitSet<ALLOCATOR, INTTYPE>& operator|= ( const BaseBitSet< ALLOCATOR, INTTYPE > &  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, INTTYPE>& operator&= ( const BaseBitSet< ALLOCATOR, INTTYPE > &  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, INTTYPE > &  src)

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

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

    ◆ MergeOr()

    Result<void> MergeOr ( const BaseBitSet< ALLOCATOR, INTTYPE > &  src)

    Merges the data from another bitset with logical OR. If the other bitset is larger it will resize this one.

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

    ◆ MergeOrNot()

    Result<void> MergeOrNot ( const BaseBitSet< ALLOCATOR, INTTYPE > &  src)

    Merges the data from another bitset with logical OR NOT. If the other bitset is larger it will resize this one.

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

    ◆ MergeAnd()

    Result<void> MergeAnd ( const BaseBitSet< ALLOCATOR, INTTYPE > &  src)

    Merges the data from another bitset with logical AND. If the other bitset is larger it will resize this one.

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

    ◆ MergeAndNot()

    Result<void> MergeAndNot ( const BaseBitSet< ALLOCATOR, INTTYPE > &  src)

    Merges the data from another bitset with logical AND NOT. If the other bitset is larger it will resize this one.

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

    ◆ MergeXOr()

    Result<void> MergeXOr ( const BaseBitSet< ALLOCATOR, INTTYPE > &  src)

    Merges the data from another bitset with logical XOR. If the other bitset is larger it will resize this one.

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

    ◆ Invert()

    void Invert ( )

    Inverts all bits of the BaseBitSet.

    ◆ 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 counting starts.
    [in]lastIndex where counting ends.
    Returns
    Number of set bits.

    ◆ GetNextSet()

    Int GetNextSet ( Int  index) const

    ◆ GetNextCleared()

    Int GetNextCleared ( Int  index) const

    ◆ GetCapacity()

    Int GetCapacity ( ) const

    Get The maximum capacity of the BitSet.

    Returns
    Number maximum bits.

    ◆ Begin()

    Gets an iterator to a const bit set to the first set bit.

    Returns
    Iterator for the first set bit (equal to End() if the set has no set bits).

    ◆ End()

    Gets an iterator to a const bit set pointing to an invalid bit (-1).

    Returns
    Iterator pointing to an invalid bit (-1).

    ◆ DescribeIO()

    static Result<void> DescribeIO ( const DataSerializeInterface stream)
    static

    Describe all elements of this class for I/O operations.

    Parameters
    [in]streamThe stream that is used to register the class members.
    Returns
    OK on success.

    ◆ GetRawData()

    const Block<const IntType>& GetRawData ( ) const

    ◆ IsSet() [2/2]

    static Bool IsSet ( const Block< const IntType > &  raw,
    Int  index 
    )
    static

    ◆ RemoveTrailingZeroes()

    void RemoveTrailingZeroes ( )
    private

    Removes trailing zero bits in the underlying 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