Gaia-ECS v0.9.3
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::cnt::bitset< NBits > Class Template Reference

Public Types

using size_type = typename size_type_selector< BitsPerItem==32 >::type
 
using iter = const_iterator< bitset >
 
using iter_inv = const_iterator_inverse< bitset >
 
using iter_rev = const_reverse_iterator< bitset >
 
using iter_rev_inv = const_reverse_inverse_iterator< bitset >
 

Public Member Functions

constexpr size_type * data ()
 
constexpr const size_type * data () const
 
GAIA_NODISCARD constexpr uint32_t items () const
 Returns the number of words used by the bitset internally.
 
constexpr iter begin () const
 
constexpr iter end () const
 
constexpr iter_rev rbegin () const
 
constexpr iter_rev rend () const
 
constexpr iter_inv ibegin () const
 
constexpr iter_inv iend () const
 
constexpr iter_rev_inv ribegin () const
 
constexpr iter_rev_inv riend () const
 
GAIA_NODISCARD constexpr bool operator[] (uint32_t pos) const
 
GAIA_NODISCARD constexpr bool operator== (const bitset &other) const
 
GAIA_NODISCARD constexpr bool operator!= (const bitset &other) const
 
constexpr void set ()
 Sets all bits.
 
constexpr void set (uint32_t pos, bool value=true)
 Sets the bit at the given position.
 
constexpr bitsetflip ()
 Flips all bits.
 
constexpr void flip (uint32_t pos)
 Flips the bit at the postion.
 
constexpr bitsetflip (uint32_t bitFrom, uint32_t bitTo)
 Flips all bits from.
 
constexpr void reset ()
 Unsets all bits.
 
constexpr void reset (uint32_t pos)
 Unsets the bit at the postion.
 
GAIA_NODISCARD constexpr bool test (uint32_t pos) const
 Returns the value of the bit at the position.
 
GAIA_NODISCARD constexpr bool all () const
 Checks if all bits are set.
 
GAIA_NODISCARD constexpr bool any () const
 Checks if any bit is set.
 
GAIA_NODISCARD constexpr bool none () const
 Checks if all bits are reset.
 
GAIA_NODISCARD uint32_t count () const
 Returns the number of set bits.
 
GAIA_NODISCARD constexpr uint32_t size () const
 Returns the number of bits the bitset can hold.
 

Public Attributes

friend iter
 
friend iter_inv
 
friend iter_rev
 
friend iter_rev_inv
 

Static Public Attributes

static constexpr uint32_t BitCount = NBits
 
static constexpr uint32_t BitsPerItem = (NBits / 64) > 0 ? 64 : 32
 
static constexpr uint32_t Items = (NBits + BitsPerItem - 1) / BitsPerItem
 

Member Function Documentation

◆ flip() [1/2]

template<uint32_t NBits>
constexpr bitset & gaia::cnt::bitset< NBits >::flip ( uint32_t  bitFrom,
uint32_t  bitTo 
)
inlineconstexpr

Flips all bits from.

Parameters
bitFromto
bitTo(including)

◆ flip() [2/2]

template<uint32_t NBits>
constexpr void gaia::cnt::bitset< NBits >::flip ( uint32_t  pos)
inlineconstexpr

Flips the bit at the postion.

Parameters
pos

◆ reset()

template<uint32_t NBits>
constexpr void gaia::cnt::bitset< NBits >::reset ( uint32_t  pos)
inlineconstexpr

Unsets the bit at the postion.

Parameters
pos

◆ set()

template<uint32_t NBits>
constexpr void gaia::cnt::bitset< NBits >::set ( uint32_t  pos,
bool  value = true 
)
inlineconstexpr

Sets the bit at the given position.

Parameters
posBit position to set (0-based, must be < NBits)
valueValue to set the bit to. Defaults to true.

◆ test()

template<uint32_t NBits>
GAIA_NODISCARD constexpr bool gaia::cnt::bitset< NBits >::test ( uint32_t  pos) const
inlineconstexpr

Returns the value of the bit at the position.

Parameters
pos

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