libhatchet
Loading...
Searching...
No Matches
hxbitset< bit_count_ > Class Template Reference

#include <hxbitset.hpp>

Public Member Functions

constexpr hxbitset (void)
constexpr hxbitset (size_t val_)
constexpr hxbitset (const hxbitset &x_)
constexpr void operator= (const hxbitset &x_)
constexpr bool operator[] (size_t pos_) const
constexpr hxbitsetoperator&= (const hxbitset &x_)
constexpr hxbitsetoperator|= (const hxbitset &x_)
constexpr hxbitsetoperator^= (const hxbitset &x_)
constexpr hxbitsetoperator<<= (size_t count_)
constexpr hxbitsetoperator>>= (size_t count_)
constexpr bool operator== (const hxbitset &x_) const
constexpr bool all (void) const
constexpr bool any (void) const
constexpr size_t * data (void)
constexpr const size_t * data (void) const
constexpr hxbitsetflip (void)
constexpr hxbitsetflip (size_t pos_)
void load (const void *src_, size_t len_)
constexpr bool none (void) const
constexpr hxbitsetreset (void)
constexpr hxbitsetreset (size_t pos_)
constexpr hxbitsetset (void)
constexpr hxbitsetset (size_t pos_, bool value_=true)
constexpr bool test (size_t pos_) const

Static Public Member Functions

static constexpr size_t bytes (void)
static constexpr size_t size (void)

Detailed Description

template<size_t bit_count_>
class hxbitset< bit_count_ >

hxbitset - A fixed-size bitset stored as an array of size_t words with no heap allocation.

  • bit_count : The number of bits in the hxbitset. Must be greater than zero.

Constructor & Destructor Documentation

◆ hxbitset() [1/3]

template<size_t bit_count_>
hxbitset< bit_count_ >::hxbitset ( void )
inlineconstexpr

Constructs a zero-initialized hxbitset.

◆ hxbitset() [2/3]

template<size_t bit_count_>
hxbitset< bit_count_ >::hxbitset ( size_t val_)
explicitconstexpr

Constructs a hxbitset from a single size_t value.

Only valid when bit_count equals the number of bits in size_t.

  • val : The value to initialize the bitset with.

◆ hxbitset() [3/3]

template<size_t bit_count_>
hxbitset< bit_count_ >::hxbitset ( const hxbitset< bit_count_ > & x_)
constexpr

Constructs a hxbitset as a copy of x.

Member Function Documentation

◆ all()

template<size_t bit_count_>
bool hxbitset< bit_count_ >::all ( void ) const
constexpr

Returns true if all bits are set.

◆ any()

template<size_t bit_count_>
bool hxbitset< bit_count_ >::any ( void ) const
constexpr

Returns true if at least one bit is set.

◆ bytes()

template<size_t bit_count_>
constexpr size_t hxbitset< bit_count_ >::bytes ( void )
inlinestaticconstexpr

Returns the size of the underlying storage in bytes.

◆ data() [1/2]

template<size_t bit_count_>
size_t * hxbitset< bit_count_ >::data ( void )
inlineconstexpr

Returns a pointer to the underlying word storage.

◆ data() [2/2]

template<size_t bit_count_>
const size_t * hxbitset< bit_count_ >::data ( void ) const
inlineconstexpr

Returns a const pointer to the underlying word storage.

◆ flip() [1/2]

template<size_t bit_count_>
hxbitset & hxbitset< bit_count_ >::flip ( size_t pos_)
constexpr

Flips the bit at position pos.

  • pos : Bit index that must be less than bit_count.

◆ flip() [2/2]

template<size_t bit_count_>
hxbitset & hxbitset< bit_count_ >::flip ( void )
constexpr

Flips all bits.

◆ load()

template<size_t bit_count_>
void hxbitset< bit_count_ >::load ( const void * src_,
size_t len_ )

Copies len bytes from src into the hxbitset storage.

Missing bytes or trailing bits beyond bit_count are masked to zero after the copy.

  • src : Pointer to the source data.
  • len : Number of bytes to copy. Must not exceed bytes().

◆ none()

template<size_t bit_count_>
bool hxbitset< bit_count_ >::none ( void ) const
inlineconstexpr

Returns true if no bits are set.

◆ operator&=()

template<size_t bit_count_>
hxbitset & hxbitset< bit_count_ >::operator&= ( const hxbitset< bit_count_ > & x_)
constexpr

Applies bitwise AND with x in place.

◆ operator<<=()

template<size_t bit_count_>
hxbitset & hxbitset< bit_count_ >::operator<<= ( size_t count_)
constexpr

Shifts all bits left by count positions, filling vacated bits with 0.

  • count : Number of positions to shift left.

◆ operator=()

template<size_t bit_count_>
void hxbitset< bit_count_ >::operator= ( const hxbitset< bit_count_ > & x_)
constexpr

Assigns the bits of x to this hxbitset.

◆ operator==()

template<size_t bit_count_>
bool hxbitset< bit_count_ >::operator== ( const hxbitset< bit_count_ > & x_) const
constexpr

Returns true if all bits compare equal to those of x.

◆ operator>>=()

template<size_t bit_count_>
hxbitset & hxbitset< bit_count_ >::operator>>= ( size_t count_)
constexpr

Shifts all bits right by count positions, filling vacated bits with 0.

  • count : Number of positions to shift right.

◆ operator[]()

template<size_t bit_count_>
bool hxbitset< bit_count_ >::operator[] ( size_t pos_) const
constexpr

Returns the value of the bit at position pos.

  • pos : Bit index. Must be less than bit_count.

◆ operator^=()

template<size_t bit_count_>
hxbitset & hxbitset< bit_count_ >::operator^= ( const hxbitset< bit_count_ > & x_)
constexpr

Applies bitwise XOR with x in place.

◆ operator|=()

template<size_t bit_count_>
hxbitset & hxbitset< bit_count_ >::operator|= ( const hxbitset< bit_count_ > & x_)
constexpr

Applies bitwise OR with x in place.

◆ reset() [1/2]

template<size_t bit_count_>
hxbitset & hxbitset< bit_count_ >::reset ( size_t pos_)
constexpr

Clears the bit at position pos.

  • pos : Bit index that must be less than bit_count.

◆ reset() [2/2]

template<size_t bit_count_>
hxbitset & hxbitset< bit_count_ >::reset ( void )
constexpr

Clears all bits to 0.

◆ set() [1/2]

template<size_t bit_count_>
hxbitset & hxbitset< bit_count_ >::set ( size_t pos_,
bool value_ = true )
constexpr

Sets or clears the bit at position pos.

  • pos : Bit index that must be less than bit_count.
  • value : The value to assign, defaults to true.

◆ set() [2/2]

template<size_t bit_count_>
hxbitset & hxbitset< bit_count_ >::set ( void )
constexpr

Sets all bits to 1.

◆ size()

template<size_t bit_count_>
constexpr size_t hxbitset< bit_count_ >::size ( void )
inlinestaticconstexpr

Returns the number of bits.

◆ test()

template<size_t bit_count_>
bool hxbitset< bit_count_ >::test ( size_t pos_) const
constexpr

Returns the value of the bit at position pos.

  • pos : Bit index must be less than bit_count.

The documentation for this class was generated from the following file: