Updated and mostly synchronized comment for BitBuffer.appendBits(), in all languages except C.
This commit is contained in:
parent
49e0902d9f
commit
f9a40a31db
|
@ -48,8 +48,8 @@ class BitBuffer final : public std::vector<bool> {
|
||||||
public: std::vector<std::uint8_t> getBytes() const;
|
public: std::vector<std::uint8_t> getBytes() const;
|
||||||
|
|
||||||
|
|
||||||
// Appends the given number of low bits of the given value
|
// Appends the given number of low bits of the given value to
|
||||||
// to this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len.
|
// this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len.
|
||||||
public: void appendBits(std::uint32_t val, int len);
|
public: void appendBits(std::uint32_t val, int len);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -93,8 +93,8 @@ public final class BitBuffer implements Cloneable {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends the specified number of low bits of the specified value
|
* Appends the specified number of low bits of the specified value to this
|
||||||
* to this sequence. Requires 0 ≤ val < 2<sup>len</sup>.
|
* sequence. Requires 0 ≤ len ≤ 31 and 0 ≤ val < 2<sup>len</sup>.
|
||||||
* @param val the value to append
|
* @param val the value to append
|
||||||
* @param len the number of low bits in the value to take
|
* @param len the number of low bits in the value to take
|
||||||
* @throws IllegalArgumentException if the value or number of bits is out of range
|
* @throws IllegalArgumentException if the value or number of bits is out of range
|
||||||
|
|
|
@ -970,8 +970,8 @@ var qrcodegen = new function() {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Appends the given number of low bits of the given value
|
// Appends the given number of low bits of the given value to
|
||||||
// to this sequence. Requires 0 <= val < 2^len.
|
// this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len.
|
||||||
this.appendBits = function(val, len) {
|
this.appendBits = function(val, len) {
|
||||||
if (len < 0 || len > 31 || val >>> len != 0)
|
if (len < 0 || len > 31 || val >>> len != 0)
|
||||||
throw "Value out of range";
|
throw "Value out of range";
|
||||||
|
|
|
@ -826,7 +826,7 @@ class _BitBuffer(list):
|
||||||
|
|
||||||
def append_bits(self, val, n):
|
def append_bits(self, val, n):
|
||||||
"""Appends the given number of low bits of the given value
|
"""Appends the given number of low bits of the given value
|
||||||
to this sequence. Requires 0 <= val < 2^n."""
|
to this sequence. Requires n >= 0 and 0 <= val < 2^n."""
|
||||||
if n < 0 or val >> n != 0:
|
if n < 0 or val >> n != 0:
|
||||||
raise ValueError("Value out of range")
|
raise ValueError("Value out of range")
|
||||||
self.extend(((val >> i) & 1) for i in reversed(range(n)))
|
self.extend(((val >> i) & 1) for i in reversed(range(n)))
|
||||||
|
|
|
@ -1069,7 +1069,7 @@ pub struct BitBuffer(pub Vec<bool>);
|
||||||
|
|
||||||
impl BitBuffer {
|
impl BitBuffer {
|
||||||
// Appends the given number of low bits of the given value
|
// Appends the given number of low bits of the given value
|
||||||
// to this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len.
|
// to this sequence. Requires len <= 31 and 0 <= val < 2^len.
|
||||||
pub fn append_bits(&mut self, val: u32, len: u8) {
|
pub fn append_bits(&mut self, val: u32, len: u8) {
|
||||||
assert!(len <= 31 && (val >> len) == 0, "Value out of range");
|
assert!(len <= 31 && (val >> len) == 0, "Value out of range");
|
||||||
self.0.extend((0 .. len as i32).rev().map(|i| get_bit(val, i))); // Append bit by bit
|
self.0.extend((0 .. len as i32).rev().map(|i| get_bit(val, i))); // Append bit by bit
|
||||||
|
|
|
@ -901,8 +901,8 @@ namespace qrcodegen {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Appends the given number of low bits of the given
|
// Appends the given number of low bits of the given value to
|
||||||
// value to this sequence. Requires 0 <= val < 2^len.
|
// this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len.
|
||||||
public appendBits(val: int, len: int): void {
|
public appendBits(val: int, len: int): void {
|
||||||
if (len < 0 || len > 31 || val >>> len != 0)
|
if (len < 0 || len > 31 || val >>> len != 0)
|
||||||
throw "Value out of range";
|
throw "Value out of range";
|
||||||
|
|
Loading…
Reference in New Issue