Tweaked BitBuffer.appendBits() comment in several language versions.

This commit is contained in:
Project Nayuki 2018-10-02 08:55:34 +00:00
parent 34408d66aa
commit dce44caf8f
3 changed files with 3 additions and 2 deletions

View File

@ -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)++)

View File

@ -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);
};

View File

@ -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