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;
|
||||
|
||||
|
||||
// Appends the given number of low bits of the given value
|
||||
// to this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len.
|
||||
// Appends the given number of low bits of the given value to
|
||||
// this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^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
|
||||
* to this sequence. Requires 0 ≤ val < 2<sup>len</sup>.
|
||||
* Appends the specified number of low bits of the specified value to this
|
||||
* sequence. Requires 0 ≤ len ≤ 31 and 0 ≤ val < 2<sup>len</sup>.
|
||||
* @param val the value to append
|
||||
* @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
|
||||
|
|
|
@ -970,8 +970,8 @@ var qrcodegen = new function() {
|
|||
return result;
|
||||
};
|
||||
|
||||
// Appends the given number of low bits of the given value
|
||||
// to this sequence. Requires 0 <= val < 2^len.
|
||||
// Appends the given number of low bits of the given value to
|
||||
// this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len.
|
||||
this.appendBits = function(val, len) {
|
||||
if (len < 0 || len > 31 || val >>> len != 0)
|
||||
throw "Value out of range";
|
||||
|
|
|
@ -826,7 +826,7 @@ class _BitBuffer(list):
|
|||
|
||||
def append_bits(self, val, n):
|
||||
"""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:
|
||||
raise ValueError("Value out of range")
|
||||
self.extend(((val >> i) & 1) for i in reversed(range(n)))
|
||||
|
|
|
@ -1069,7 +1069,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 <= 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) {
|
||||
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
|
||||
|
|
|
@ -901,8 +901,8 @@ namespace qrcodegen {
|
|||
}
|
||||
|
||||
|
||||
// Appends the given number of low bits of the given
|
||||
// value to this sequence. Requires 0 <= val < 2^len.
|
||||
// Appends the given number of low bits of the given value to
|
||||
// this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len.
|
||||
public appendBits(val: int, len: int): void {
|
||||
if (len < 0 || len > 31 || val >>> len != 0)
|
||||
throw "Value out of range";
|
||||
|
|
Loading…
Reference in New Issue