Tweaked BitBuffer.appendBits() comment in several language versions.
This commit is contained in:
parent
34408d66aa
commit
dce44caf8f
|
@ -177,6 +177,7 @@ bool qrcodegen_encodeBinary(uint8_t dataAndTemp[], size_t dataLen, uint8_t qrcod
|
|||
|
||||
|
||||
// Appends the given sequence of bits to the given byte-based bit buffer, increasing the bit length.
|
||||
// Requires 0 <= numBits <= 16 and 0 <= val < 2^numBits.
|
||||
testable void appendBitsToBuffer(unsigned int val, int numBits, uint8_t buffer[], int *bitLen) {
|
||||
assert(0 <= numBits && numBits <= 16 && (unsigned long)val >> numBits == 0);
|
||||
for (int i = numBits - 1; i >= 0; i--, (*bitLen)++)
|
||||
|
|
|
@ -49,7 +49,7 @@ class BitBuffer final : public std::vector<bool> {
|
|||
|
||||
|
||||
// Appends the given number of low bits of the given value
|
||||
// to this sequence. Requires 0 <= val < 2^len.
|
||||
// to this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len.
|
||||
public: void appendBits(std::uint32_t val, int len);
|
||||
|
||||
};
|
||||
|
|
|
@ -1065,7 +1065,7 @@ pub struct BitBuffer(pub Vec<bool>);
|
|||
|
||||
impl BitBuffer {
|
||||
// Appends the given number of low bits of the given value
|
||||
// to this sequence. Requires 0 <= val < 2^len.
|
||||
// to this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len.
|
||||
pub fn append_bits(&mut self, val: u32, len: u8) {
|
||||
assert!(len < 32 && (val >> len) == 0 || len == 32, "Value out of range");
|
||||
self.0.extend((0 .. len as i32).rev().map(|i| get_bit(val, i))); // Append bit by bit
|
||||
|
|
Loading…
Reference in New Issue