|
|
| BitVector (size_t bit_count=0) |
| |
|
| BitVector (const BitVector &source) |
| |
| BitVector & | operator= (const BitVector &rhs) |
| |
| bool | Equals (const BitVector &rhs, size_t bits_to_compare) const |
| |
| bool | Equals (const BitVector &rhs) const |
| |
| void | SetBitCount (size_t bit_count) |
| |
| size_t | GetBitCount () const |
| |
| void | Clip (size_t bit_count) |
| |
| void | Clear () |
| |
| void | Set (size_t index) |
| |
| void | Unset (size_t index) |
| |
| bool | Get (size_t index) const |
| |
| void | Flip (size_t index) |
| |
| template<typename IntegerType = uint64_t> |
| IntegerType | GetInt (size_t bit_index, size_t bit_width) const |
| |
| template<typename IntegerType = uint64_t> |
| void | SetInt (IntegerType value, size_t bit_index, size_t bit_width) |
| |
| void | SubVector (BitVector *destination, size_t destination_start_bit_offset, size_t source_start_bit_offset, size_t bits_to_copy) const |
| |
| size_t | HammingDistance (const BitVector &rhs) const |
| |
| size_t | ToString (char *buffer, size_t buffer_length) const |
| |
| void | FromString (const char *buffer, size_t buffer_length) |
| |
| size_t | ToStringHex (char *buffer, size_t buffer_length) const |
| |
| void | FromStringHex (const char *buffer, size_t buffer_length) |
| |
|
| const std::vector< std::byte > & | GetBytes () const |
| |
| std::vector< std::byte > & | GetBytesWritable () |
| |
| void | Resize (size_t bit_count) |
| |
|
void | WriteToStream (std::ostream &out) const |
| |
|
void | WriteToStreamHex (std::ostream &out) const |
| |
|
| template<typename IntegerType = uint64_t> |
| static void | WriteInt (std::byte *bytes, size_t start_bit_index, size_t bits_to_copy, IntegerType value) |
| |
| template<typename IntegerType = uint64_t> |
| static IntegerType | ReadInt (const std::byte *bytes, size_t start_bit_index, size_t bits_to_copy) |
| |
| static void | WriteBytes (const std::byte *source, size_t source_start_bit_offset, std::byte *destination, size_t destination_start_bit_offset, size_t bits_to_copy) |
| |
| static bool | Compare (const std::byte *left, const std::byte *right, size_t bits_to_compare) |
| |
◆ Clear()
| void panga::BitVector::Clear |
( |
| ) |
|
◆ Clip()
| void panga::BitVector::Clip |
( |
size_t |
bit_count | ) |
|
Clip the length of the BitVector.
Does not reduce the size of the backing storage.
Note: Cannot grow the BitVector (bitCount must be less than current count).
◆ Compare()
| bool panga::BitVector::Compare |
( |
const std::byte * |
left, |
|
|
const std::byte * |
right, |
|
|
size_t |
bits_to_compare |
|
) |
| |
|
staticprotected |
Compare |bits_to_compare| bits between |left| and |right|.
Note: Does not support non-byte-aligned compare, begins comparing at the beginning of each byte array.
◆ Equals() [1/2]
| bool panga::BitVector::Equals |
( |
const BitVector & |
rhs | ) |
const |
Calculate equality between this BitVector and |rhs|.
Note: Compares up to the number of bits in |this| BitVector.
◆ Equals() [2/2]
| bool panga::BitVector::Equals |
( |
const BitVector & |
rhs, |
|
|
size_t |
bits_to_compare |
|
) |
| const |
Calculate equality between this BitVector and |rhs|.
- Parameters
-
| bits_to_compare | Limit comparision to only the first bits_to_compare bits. |
◆ Flip()
| void panga::BitVector::Flip |
( |
size_t |
index | ) |
|
Flip one bit in the BitVector.
- Parameters
-
| index | The index of the bit to flip. |
◆ FromString()
| void panga::BitVector::FromString |
( |
const char * |
buffer, |
|
|
size_t |
buffer_length |
|
) |
| |
Read a BitVector from a null-terminated string of '0' and '1' characters.
- Parameters
-
| buffer | String which we will read from. |
| buffer_length | Length of buffer in bytes. |
◆ FromStringHex()
| void panga::BitVector::FromStringHex |
( |
const char * |
buffer, |
|
|
size_t |
buffer_length |
|
) |
| |
Read a BitVector from a null-terminated string containing a hex representation.
- Parameters
-
| buffer | String which we will read from. |
| buffer_length | Length of buffer in bytes. |
◆ Get()
| bool panga::BitVector::Get |
( |
size_t |
index | ) |
const |
Get a single bit from the BitVector.
- Parameters
-
| index | The index of the bit to get. |
- Returns
- true if bit is set.
◆ GetBitCount()
| size_t panga::BitVector::GetBitCount |
( |
| ) |
const |
◆ GetBytes()
| const std::vector< std::byte > & panga::BitVector::GetBytes |
( |
| ) |
const |
|
protected |
Get a read-only view of the byte buffer underlying this BitVector.
◆ GetBytesWritable()
| std::vector< std::byte > & panga::BitVector::GetBytesWritable |
( |
| ) |
|
|
protected |
Get a writable view of the byte buffer underlying this BitVector.
◆ GetInt()
template<typename IntegerType = uint64_t>
| IntegerType panga::BitVector::GetInt |
( |
size_t |
bit_index, |
|
|
size_t |
bit_width |
|
) |
| const |
|
inline |
Construct an integer from bits in the BitVector.
- Parameters
-
| bit_index | Starting bit index in the BitVector at which to fetch the integer. |
| bit_width | Number of bits to use in constructing the integer. |
◆ HammingDistance()
| size_t panga::BitVector::HammingDistance |
( |
const BitVector & |
rhs | ) |
const |
Calculate the Hamming Distance between this and |rhs|.
The Hamming Distance is the number of bits which differ between two BitVectors.
- Returns
- The number of bits which differ between this and |rhs|.
◆ operator=()
Deep copy a BitVector.
Resizes this to be the same size as rhs.
◆ ReadInt()
template<typename IntegerType = uint64_t>
| static IntegerType panga::BitVector::ReadInt |
( |
const std::byte * |
bytes, |
|
|
size_t |
start_bit_index, |
|
|
size_t |
bits_to_copy |
|
) |
| |
|
inlinestaticprotected |
Read |bits_to_copy| bits from |bytes| starting at |start_bit_index| and interpret them as an integer type value.
◆ Resize()
| void panga::BitVector::Resize |
( |
size_t |
bit_count | ) |
|
|
protected |
Resize the BitVector such that it contains |bit_count| bits. Note: Does not change the value of any existing bits currently in the vector.
◆ Set()
| void panga::BitVector::Set |
( |
size_t |
index | ) |
|
Set a single bit the BitVector.
- Parameters
-
| index | The index of the bit to set. |
◆ SetBitCount()
| void panga::BitVector::SetBitCount |
( |
size_t |
bit_count | ) |
|
◆ SetInt()
template<typename IntegerType = uint64_t>
| void panga::BitVector::SetInt |
( |
IntegerType |
value, |
|
|
size_t |
bit_index, |
|
|
size_t |
bit_width |
|
) |
| |
|
inline |
Store an integer value in the BitVector.
- Parameters
-
| value | Value of the integer to store. |
| bit_index | Starting bit index in the BitVector at which to store the integer. |
| bit_width | Number of bits to store in this BitVector for the integer. |
◆ SubVector()
| void panga::BitVector::SubVector |
( |
BitVector * |
destination, |
|
|
size_t |
destination_start_bit_offset, |
|
|
size_t |
source_start_bit_offset, |
|
|
size_t |
bits_to_copy |
|
) |
| const |
Copy a range of bits from this vector.
- Parameters
-
| destination | BitVector into which we'll write bits from this. |
| destination_start_bit_offset | Bit index into destination where we will start writing. |
| source_start_bit_offset | Bit index into this where we will start copying. |
| bits_to_copy | Count of bits we should copy. |
◆ ToString()
| size_t panga::BitVector::ToString |
( |
char * |
buffer, |
|
|
size_t |
buffer_length |
|
) |
| const |
Write a binary representation of this BitVector into a buffer.
The buffer will be null-terminated.
Each character in the resulting buffer will be a '0' or '1'.
The most-significant bit is written at the beginning of the buffer. Note: buffer_length must be > bitCount.
- Parameters
-
| buffer | Buffer which we will write into. |
| buffer_length | Length of buffer in bytes. |
- Returns
- If buffer is nullptr, returns the number of bytes needed to store the binary representation of this BitVector. Otherwise, returns the number of bytes written to buffer.
◆ ToStringHex()
| size_t panga::BitVector::ToStringHex |
( |
char * |
buffer, |
|
|
size_t |
buffer_length |
|
) |
| const |
Write a hex representation of this BitVector into a buffer.
The buffer will be null-terminated.
Note: buffer_length must be > bitCount / 8 * 2.
- See also
- BitVector::HexFormat
- Parameters
-
| buffer | Buffer which we will write into. |
| buffer_length | Length of buffer in bytes. |
- Returns
- If buffer is nullptr, returns the number of bytes needed to store the hex representation of this BitVector. Otherwise, returns the number of bytes written to buffer.
◆ Unset()
| void panga::BitVector::Unset |
( |
size_t |
index | ) |
|
Unset a single bit in the BitVector.
- Parameters
-
| index | The index of the bit to unset. |
◆ WriteBytes()
| void panga::BitVector::WriteBytes |
( |
const std::byte * |
source, |
|
|
size_t |
source_start_bit_offset, |
|
|
std::byte * |
destination, |
|
|
size_t |
destination_start_bit_offset, |
|
|
size_t |
bits_to_copy |
|
) |
| |
|
staticprotected |
Copy |bits_to_copy| bits from a byte buffer |source| into |destination|.
|source_start_bit_offset| and |destination_start_bit_offset| are bit offsets into |source| and |destination|.
Supports non-byte-aligned copy, though this is slower.
◆ WriteInt()
template<typename IntegerType = uint64_t>
| static void panga::BitVector::WriteInt |
( |
std::byte * |
bytes, |
|
|
size_t |
start_bit_index, |
|
|
size_t |
bits_to_copy, |
|
|
IntegerType |
value |
|
) |
| |
|
inlinestaticprotected |
Write |bits_to_copy| bits from an integer type |value| as binary data into |bytes| beginning at |start_bit_index|.
◆ HexFormat
The documentation for this class was generated from the following files: