A simple, fast array of bits.
- Full name:
\BaconQrCode\Common\BitArray
- This class is marked as final and can't be subclassed
- This class is a Final class
Bits represented as an array of integers.
private \SplFixedArray<int> $bits
Size of the bit array in bits.
private int $size
Creates a new bit array with a given size.
public __construct(int $size): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$size |
int |
Gets the size in bits.
public getSize(): int
Gets the size in bytes.
public getSizeInBytes(): int
Ensures that the array has a minimum capacity.
public ensureCapacity(int $size): void
Parameters:
Parameter | Type | Description |
---|---|---|
$size |
int |
Gets a specific bit.
public get(int $i): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$i |
int |
Sets a specific bit.
public set(int $i): void
Parameters:
Parameter | Type | Description |
---|---|---|
$i |
int |
Flips a specific bit.
public flip(int $i): void
Parameters:
Parameter | Type | Description |
---|---|---|
$i |
int |
Gets the next set bit position from a given position.
public getNextSet(int $from): int
Parameters:
Parameter | Type | Description |
---|---|---|
$from |
int |
Gets the next unset bit position from a given position.
public getNextUnset(int $from): int
Parameters:
Parameter | Type | Description |
---|---|---|
$from |
int |
Sets a bulk of bits.
public setBulk(int $i, int $newBits): void
Parameters:
Parameter | Type | Description |
---|---|---|
$i |
int | |
$newBits |
int |
Sets a range of bits.
public setRange(int $start, int $end): void
Parameters:
Parameter | Type | Description |
---|---|---|
$start |
int | |
$end |
int |
Clears the bit array, unsetting every bit.
public clear(): void
Checks if a range of bits is set or not set.
public isRange(int $start, int $end, bool $value): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$start |
int | |
$end |
int | |
$value |
bool |
Appends a bit to the array.
public appendBit(bool $bit): void
Parameters:
Parameter | Type | Description |
---|---|---|
$bit |
bool |
Appends a number of bits (up to 32) to the array.
public appendBits(int $value, int $numBits): void
Parameters:
Parameter | Type | Description |
---|---|---|
$value |
int | |
$numBits |
int |
Appends another bit array to this array.
public appendBitArray(self $other): void
Parameters:
Parameter | Type | Description |
---|---|---|
$other |
self |
Makes an exclusive-or comparision on the current bit array.
public xorBits(self $other): void
Parameters:
Parameter | Type | Description |
---|---|---|
$other |
self |
Converts the bit array to a byte array.
public toBytes(int $bitOffset, int $numBytes): \SplFixedArray<int>
Parameters:
Parameter | Type | Description |
---|---|---|
$bitOffset |
int | |
$numBytes |
int |
Gets the internal bit array.
public getBitArray(): \SplFixedArray<int>
Reverses the array.
public reverse(): void
Returns a string representation of the bit array.
public __toString(): string