\BaconQrCode\CommonBitArray

A simple, fast array of bits.

Summary

Methods
Properties
Constants
__construct()
getSize()
getSizeInBytes()
ensureCapacity()
get()
set()
flip()
getNextSet()
getNextUnset()
setBulk()
setRange()
clear()
isRange()
appendBit()
appendBits()
appendBitArray()
xorBits()
toBytes()
getBitArray()
reverse()
__toString()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$bits
$size
N/A

Properties

$bits

$bits : \SplFixedArray<int>

Bits represented as an array of integers.

Type

SplFixedArray

$size

$size : int

Size of the bit array in bits.

Type

int

Methods

__construct()

__construct(int  $size) : mixed

Creates a new bit array with a given size.

Parameters

int $size

Returns

mixed —

getSize()

getSize() : int

Gets the size in bits.

Returns

int —

getSizeInBytes()

getSizeInBytes() : int

Gets the size in bytes.

Returns

int —

ensureCapacity()

ensureCapacity(int  $size) : void

Ensures that the array has a minimum capacity.

Parameters

int $size

get()

get(int  $i) : bool

Gets a specific bit.

Parameters

int $i

Returns

bool —

set()

set(int  $i) : void

Sets a specific bit.

Parameters

int $i

flip()

flip(int  $i) : void

Flips a specific bit.

Parameters

int $i

getNextSet()

getNextSet(int  $from) : int

Gets the next set bit position from a given position.

Parameters

int $from

Returns

int —

getNextUnset()

getNextUnset(int  $from) : int

Gets the next unset bit position from a given position.

Parameters

int $from

Returns

int —

setBulk()

setBulk(int  $i, int  $newBits) : void

Sets a bulk of bits.

Parameters

int $i
int $newBits

setRange()

setRange(int  $start, int  $end) : void

Sets a range of bits.

Parameters

int $start
int $end

Throws

\BaconQrCode\Exception\InvalidArgumentException

if end is smaller than start

clear()

clear() : void

Clears the bit array, unsetting every bit.

isRange()

isRange(int  $start, int  $end, bool  $value) : bool

Checks if a range of bits is set or not set.

Parameters

int $start
int $end
bool $value

Throws

\BaconQrCode\Exception\InvalidArgumentException

if end is smaller than start

Returns

bool —

appendBit()

appendBit(bool  $bit) : void

Appends a bit to the array.

Parameters

bool $bit

appendBits()

appendBits(int  $value, int  $numBits) : void

Appends a number of bits (up to 32) to the array.

Parameters

int $value
int $numBits

Throws

\BaconQrCode\Exception\InvalidArgumentException

if num bits is not between 0 and 32

appendBitArray()

appendBitArray(self  $other) : void

Appends another bit array to this array.

Parameters

self $other

xorBits()

xorBits(self  $other) : void

Makes an exclusive-or comparision on the current bit array.

Parameters

self $other

Throws

\BaconQrCode\Exception\InvalidArgumentException

if sizes don't match

toBytes()

toBytes(int  $bitOffset, int  $numBytes) : \SplFixedArray<int>

Converts the bit array to a byte array.

Parameters

int $bitOffset
int $numBytes

Returns

\SplFixedArray

getBitArray()

getBitArray() : \SplFixedArray<int>

Gets the internal bit array.

Returns

\SplFixedArray

reverse()

reverse() : void

Reverses the array.

__toString()

__toString() : string

Returns a string representation of the bit array.

Returns

string —