jaulib v1.4.0-2-g788cf73
Jau Support Library (C++, Java, ..)
|
Simple dynamically heap-sized bitheap for efficient bit storage access in O(1). More...
#include <bitheap.hpp>
Public Types | |
typedef size_t | size_type |
size_t data type, bit position and count | |
typedef unsigned long | unit_type |
Unit data type. | |
Public Member Functions | |
constexpr | bitheap (size_type bitSize) noexcept |
Constructs an empty bitheap instance. | |
bitheap (std::string_view bitstr) | |
Constructs a bitheap instance, initialized with bitstr msb bit-pattern. | |
constexpr void | clear () noexcept |
constexpr bool | clr (size_type bitpos) noexcept |
Clear the bit at position bitpos of this storage. | |
bool | copy (size_type srcBitpos, size_type dstBitpos) noexcept |
Copies the bit at position srcBitpos to position dstBitpos , returning the copied bit-value. | |
bool | copyUnit (size_type srcBitpos, size_type dstBitpos, size_type length) noexcept |
Copies length bits at position srcBitpos to position dstBitpos , returning the copied bits. | |
size_type | count () const noexcept |
constexpr bitheap & | flip () noexcept |
constexpr bool | flip (size_type bitpos) noexcept |
Flips the bit value at position bitpos in this storage. | |
constexpr bool | get (size_type bitpos) const noexcept |
unit_type | getUnit (size_type bitpos, size_type length) const noexcept |
constexpr bool | in_range (size_type bitpos) const noexcept |
constexpr bool | in_range (size_type bitpos, size_type length) const noexcept |
std::string | infoString () const noexcept |
constexpr bool | operator== (const bitheap &rhs) const noexcept |
constexpr bool | operator[] (size_type bitpos) const noexcept |
bool | put (size_t bitpos, const bitheap &o) |
constexpr bool | put (size_type bitpos, bool v) noexcept |
Writes the bit value v to position bitpos into this storage. | |
bool | put (size_type bitpos, std::string_view bitstr) noexcept |
Writes bitstr msb bit-pattern into this storage, starting with the lowest bit from the storage position bitpos . | |
bool | putUnit (size_type bitpos, size_type length, unit_type data) noexcept |
Writes length bits of given data into this storage, starting with the lowest bit from the storage position bitpos . | |
constexpr bitheap & | reset () noexcept |
constexpr bool | reset (size_type bitpos) noexcept |
Clear the bit at position bitpos of this storage. | |
void | resize (size_t new_bit_size) |
constexpr bitheap & | reverse () noexcept |
constexpr bool | set (size_type bitpos) noexcept |
Sets the bit at position bitpos of this storage. | |
bool | set (size_type bitpos, size_type length, bool bit) noexcept |
Set length bits starting at bitpos of this bitfield to the given value bit . | |
bitheap & | setAll (bool bit) noexcept |
Set all bits of this bitfield to the given value bit . | |
constexpr size_type | size () const noexcept |
Returns storage size in bits. | |
std::pair< bitheap, bool > | subbits (size_type bitpos, size_type length) const noexcept |
std::string | toString (PrefixOpt prefix=PrefixOpt::none) const noexcept |
std::string | toString (size_type bitpos, size_type length, PrefixOpt prefix=PrefixOpt::none) const noexcept |
Static Public Attributes | |
static constexpr size_type | unit_bit_size = unit_byte_size * CHAR_BIT |
One unit size in bits. | |
static constexpr size_type | unit_byte_size = sizeof(unit_type) |
One unit size in bytes. | |
static constexpr size_type | unit_shift = jau::log2_byteshift(unit_byte_size) |
One unit shift amount. | |
Simple dynamically heap-sized bitheap for efficient bit storage access in O(1).
Bit-position and bit-order are in least-significant-bits (lsb) first.
Implementations utilizes a dynamic heap std::vector<unsigned long>
StorageType.
Similar to std::bitset, but utilizing dynamic runtime heapsize and providing custom methods.
Definition at line 49 of file bitheap.hpp.
typedef unsigned long jau::bitheap::unit_type |
Unit data type.
Definition at line 51 of file bitheap.hpp.
typedef size_t jau::bitheap::size_type |
size_t data type, bit position and count
Definition at line 52 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Constructs an empty bitheap instance.
Definition at line 78 of file bitheap.hpp.
|
inline |
Constructs a bitheap instance, initialized with bitstr
msb bit-pattern.
bitstr | most-significat (msb) bit string pattern |
jau::IllegalArgumentError | if bitstr put failed |
Definition at line 90 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Returns storage size in bits.
Definition at line 58 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Definition at line 73 of file bitheap.hpp.
|
inline |
Definition at line 101 of file bitheap.hpp.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Definition at line 112 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Definition at line 118 of file bitheap.hpp.
|
inlineconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
Writes the bit value v
to position bitpos
into this storage.
Definition at line 133 of file bitheap.hpp.
|
inlinenodiscardconstexprnoexcept |
Flips the bit value at position bitpos
in this storage.
Definition at line 151 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Definition at line 166 of file bitheap.hpp.
|
inlineconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
Sets the bit at position bitpos
of this storage.
Definition at line 202 of file bitheap.hpp.
|
inlinenodiscardconstexprnoexcept |
Clear the bit at position bitpos
of this storage.
Definition at line 207 of file bitheap.hpp.
|
inlinenodiscardconstexprnoexcept |
Clear the bit at position bitpos
of this storage.
Definition at line 212 of file bitheap.hpp.
Copies the bit at position srcBitpos
to position dstBitpos
, returning the copied bit-value.
Definition at line 218 of file bitheap.hpp.
|
inlinenodiscardnoexcept |
Writes length
bits of given data
into this storage, starting with the lowest bit from the storage position bitpos
.
Definition at line 253 of file bitheap.hpp.
|
inlinenodiscardnoexcept |
Writes bitstr
msb bit-pattern into this storage, starting with the lowest bit from the storage position bitpos
.
bitpos | bit position to insert |
bitstr | most-significat (msb) bit string pattern |
Definition at line 289 of file bitheap.hpp.
Set length
bits starting at bitpos
of this bitfield to the given value bit
.
Definition at line 315 of file bitheap.hpp.
|
inlinenoexcept |
Set all bits of this bitfield to the given value bit
.
Definition at line 353 of file bitheap.hpp.
|
inlinenodiscardnoexcept |
Copies length
bits at position srcBitpos
to position dstBitpos
, returning the copied bits.
Definition at line 362 of file bitheap.hpp.
|
inlinenoexcept |
Definition at line 367 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Definition at line 374 of file bitheap.hpp.
|
inlinenodiscard |
Definition at line 388 of file bitheap.hpp.
|
inlinenoexcept |
|
inlinenoexcept |
Definition at line 479 of file bitheap.hpp.
|
inlinenoexcept |
Definition at line 483 of file bitheap.hpp.
One unit size in bytes.
Definition at line 53 of file bitheap.hpp.
|
staticconstexpr |
One unit size in bits.
Definition at line 54 of file bitheap.hpp.
|
staticconstexpr |
One unit shift amount.
Definition at line 55 of file bitheap.hpp.