BitArray class
#include <nCine/Base/BitArray.h>
Dynamically allocated array of bits.
Stores an arbitrary number of bits in a heap buffer and exposes per-bit access together with bitwise, shift and increment/decrement operators. The array is move-only.
Constructors, destructors, conversion operators
- BitArray()
-
BitArray(ValueInitT,
std::
size_t sizeInBits) - Creates an array of the given size in bits with all bits cleared.
-
BitArray(NoInitT,
std::
size_t sizeInBits) - Creates an array of the given size in bits without initializing its contents.
- ~BitArray()
- BitArray(const BitArray&) deleted
- BitArray(BitArray&& other) noexcept
Public functions
- auto operator=(const BitArray&) -> BitArray& deleted
- auto operator=(BitArray&& other) -> BitArray& noexcept
- auto data() -> char*
- Returns a pointer to the underlying byte buffer.
- auto empty() const -> bool
- Returns
trueif the array contains no bits. -
auto size() const -> std::
size_t - Returns the size of the array in bits.
-
auto sizeInBytes() const -> std::
size_t - Returns the size of the underlying buffer in bytes.
-
void resize(ValueInitT,
std::
size_t sizeInBits) - Resizes the array to the given size in bits, clearing its contents.
-
void resize(NoInitT,
std::
size_t sizeInBits) - Resizes the array to the given size in bits without initializing its contents.
- void setAll()
- Sets every bit in the array.
- void resetAll()
- Clears every bit in the array.
-
void set(std::
size_t bit) - Sets the bit at the specified position.
-
void set(std::
size_t bit, bool value) - Sets or clears the bit at the specified position.
-
void reset(std::
size_t bit) - Clears the bit at the specified position.
-
auto operator()(const std::
size_t bit) -> BitArrayIndex - Returns a writable proxy to the bit at the specified position.
-
auto operator[](std::
size_t bit) const -> bool - Returns the value of the bit at the specified position.
- auto operator==(const BitArray& other) const -> bool
- Returns
trueif both arrays have the same size and contents. - auto operator&(const BitArray& other) const -> BitArray
- Returns the bitwise AND of two arrays.
- auto operator^(const BitArray& other) const -> BitArray
- Returns the bitwise XOR of two arrays.
- auto operator|(const BitArray& other) const -> BitArray
- Returns the bitwise OR of two arrays.
- auto operator~() const -> BitArray
- Returns the bitwise complement of the array.
-
auto operator<<(std::
size_t count) const -> BitArray - Returns the array shifted left by the specified number of bits.
-
auto operator>>(std::
size_t count) const -> BitArray - Returns the array shifted right by the specified number of bits.
- auto operator++() -> BitArray&
- auto operator++(int) -> BitArray&
- auto operator--() -> BitArray&
- auto operator--(int) -> BitArray&
- auto operator&=(const BitArray& src) -> BitArray&
- auto operator^=(const BitArray& src) -> BitArray&
- auto operator|=(const BitArray& src) -> BitArray&
- auto notAll() -> BitArray&
- Replaces the array with its bitwise complement.
-
auto operator<<=(std::
size_t shifts) -> BitArray& -
auto operator>>=(std::
size_t shifts) -> BitArray&