|
jaulib v1.4.1
Jau Support Library (C++, Java, ..)
|
Simple dynamically heap-sized bitheap for efficient bit storage access. More...
#include <bitheap.hpp>
Public Types | |
| typedef size_t | size_type |
| size_t data type, bit position and count | |
| typedef jau::nsize_t | 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.
Bit-position and bit-order are in least-significant-bits (lsb) first.
Implementations utilizes a dynamic heap std::vector<jau::nsize_t> StorageType.
Similar to std::bitset, but utilizing dynamic runtime heapsize and providing custom methods.
Definition at line 50 of file bitheap.hpp.
| typedef jau::nsize_t jau::bitheap::unit_type |
Unit data type.
Definition at line 52 of file bitheap.hpp.
| typedef size_t jau::bitheap::size_type |
size_t data type, bit position and count
Definition at line 53 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Constructs an empty bitheap instance.
Definition at line 79 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 91 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Returns storage size in bits.
Definition at line 59 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Definition at line 74 of file bitheap.hpp.
|
inline |
Definition at line 102 of file bitheap.hpp.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Definition at line 113 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Definition at line 119 of file bitheap.hpp.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Writes the bit value v to position bitpos into this storage.
Definition at line 134 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Flips the bit value at position bitpos in this storage.
Definition at line 152 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Definition at line 167 of file bitheap.hpp.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Sets the bit at position bitpos of this storage.
Definition at line 203 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Clear the bit at position bitpos of this storage.
Definition at line 208 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Clear the bit at position bitpos of this storage.
Definition at line 213 of file bitheap.hpp.
Copies the bit at position srcBitpos to position dstBitpos, returning the copied bit-value.
Definition at line 219 of file bitheap.hpp.
Writes length bits of given data into this storage, starting with the lowest bit from the storage position bitpos.
Definition at line 254 of file bitheap.hpp.
|
inlinenoexcept |
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 290 of file bitheap.hpp.
Set length bits starting at bitpos of this bitfield to the given value bit.
Definition at line 316 of file bitheap.hpp.
|
inlinenoexcept |
Set all bits of this bitfield to the given value bit.
Definition at line 354 of file bitheap.hpp.
|
inlinenoexcept |
Copies length bits at position srcBitpos to position dstBitpos, returning the copied bits.
Definition at line 363 of file bitheap.hpp.
|
inlinenoexcept |
Definition at line 368 of file bitheap.hpp.
|
inlineconstexprnoexcept |
Definition at line 375 of file bitheap.hpp.
|
inline |
Definition at line 389 of file bitheap.hpp.
|
inlinenoexcept |
|
inlinenoexcept |
Definition at line 480 of file bitheap.hpp.
|
inlinenoexcept |
Definition at line 484 of file bitheap.hpp.
One unit size in bytes.
Definition at line 54 of file bitheap.hpp.
|
staticconstexpr |
One unit size in bits.
Definition at line 55 of file bitheap.hpp.
|
staticconstexpr |
One unit shift amount.
Definition at line 56 of file bitheap.hpp.