BitArray

BitArray() :BitArray : public ArrayAccess, public Countable, public IteratorAggregate, public JsonSerializable

Public Functions

chdemko\BitArray\BitArray::__clone()

Clone a BitArray

Since

1.0.0

return:

void

chdemko\BitArray\BitArray::__toString()

Convert the object to a string

Since

1.0.0

return:

string String representation of this object

chdemko\BitArray\BitArray::__get( $property)

Magic get method

Since

1.0.0

param $property:

The property

throws RuntimeException:

If the property does not exist

return:

mixed The value associated to the property

chdemko\BitArray\BitArray::offsetExists( $offset)

Test the existence of an index

Since

1.0.0

param $offset:

The offset

return:

boolean The truth value

chdemko\BitArray\BitArray::offsetGet( $offset)

Get the truth value for an index

Since

1.0.0

param $offset:

The offset

throws OutOfRangeException:

Argument index must be an positive integer lesser than the size

return:

boolean The truth value

chdemko\BitArray\BitArray::offsetSet( $offset,  $value)

Set the truth value for an index

Since

1.0.0

param $offset:

The offset

param $value:

The truth value

throws OutOfRangeException:

Argument index must be an positive integer lesser than the size

return:

void

chdemko\BitArray\BitArray::offsetUnset( $offset)

Unset the existence of an index

Since

1.0.0

param $offset:

The index

throws RuntimeException:

Values cannot be unset

return:

void

chdemko\BitArray\BitArray::count()

Return the number of true bits

Since

1.0.0

return:

integer The number of true bits

chdemko\BitArray\BitArray::toArray()

Transform the object to an array

Since

1.1.0

return:

array Array of values

chdemko\BitArray\BitArray::jsonSerialize()

Serialize the object

Since

1.0.0

return:

array Array of values

chdemko\BitArray\BitArray::getIterator()

Get an iterator

Since

1.0.0

return:

Iterator Iterator

chdemko\BitArray\BitArray::size()

Return the size

Since

1.0.0

return:

integer The size

chdemko\BitArray\BitArray::directCopy(BitArray $bits,  $index = 0,  $offset = 0,  $size = 0)

Copy bits directly from a BitArray

Since

1.1.0

param $bits:

A BitArray to copy

param $index:

Starting index for destination

param $offset:

Starting index for copying

param $size:

Copy size

throws OutOfRangeException:

Argument index must be an positive integer lesser than the size

return:

BitArray This object for chaining

chdemko\BitArray\BitArray::copy(BitArray $bits,  $index = 0,  $offset = 0,  $size = null)

Copy bits from a BitArray

Since

1.1.0

param $bits:

A BitArray to copy

param $index:

Starting index for destination. If index is non-negative, the index parameter is used as it is, keeping its real value between 0 and size-1. If index is negative, the index parameter starts from the end, keeping its real value between 0 and size-1.

param $offset:

Starting index for copying. If offset is non-negative, the offset parameter is used as it is, keeping its positive value between 0 and size-1. If offset is negative, the offset parameter starts from the end, keeping its real value between 0 and size-1.

param $size:

Copy size. If size is given and is positive, then the copy will copy size elements. If the bits argument is shorter than the size, then only the available elements will be copied. If size is given and is negative then the copy starts from the end. If it is omitted, then the copy will have everything from offset up until the end of the bits argument.

return:

BitArray This object for chaining

chdemko\BitArray\BitArray::applyComplement()

Complement the bit array

Since

1.0.0

return:

BitArray This object for chaining

chdemko\BitArray\BitArray::applyOr(BitArray $bits)

Or with an another bit array

Since

1.0.0

param $bits:

A bit array

throws InvalidArgumentException:

Argument must be of equal size

return:

BitArray This object for chaining

chdemko\BitArray\BitArray::applyAnd(BitArray $bits)

And with an another bit array

Since

1.0.0

param $bits:

A bit array

throws InvalidArgumentException:

Argument must be of equal size

return:

BitArray This object for chaining

chdemko\BitArray\BitArray::applyXor(BitArray $bits)

Xor with an another bit array

Since

1.0.0

param $bits:

A bit array

throws InvalidArgumentException:

Argument must be of equal size

return:

BitArray This object for chaining

chdemko\BitArray\BitArray::shift( $size = 1,  $value = false)

Shift a bit array.

Since

1.2.0

param $size:

Size to shift. Negative value means the shifting is done right to left while positive value means the shifting is done left to right.

param $value:

Value to shift

return:

BitArray $this for chaining

Public Static Functions

static chdemko\BitArray\BitArray::fromInteger( $size,  $default = false)

Create a new BitArray from an integer

Since

1.0.0

param $size:

Size of the BitArray

param $default:

The default value for bits

return:

BitArray A new BitArray

static chdemko\BitArray\BitArray::fromDecimal( $size,  $values = 0)

Create a new BitArray from a sequence of bits.

Since

1.2.0

param $size:

Size of the BitArray

param $values:

The values for the bits

return:

BitArray A new BitArray

static chdemko\BitArray\BitArray::fromTraversable( $traversable)

Create a new BitArray from a traversable

Since

1.0.0

param $traversable:

A traversable and countable

return:

BitArray A new BitArray

static chdemko\BitArray\BitArray::fromString( $string)

Create a new BitArray from a bit string

Since

1.0.0

param $string:

A bit string

return:

BitArray A new BitArray

static chdemko\BitArray\BitArray::fromJson( $json)

Create a new BitArray from json

Since

1.0.0

param $json:

A json encoded value

return:

BitArray A new BitArray

static chdemko\BitArray\BitArray::fromSlice(BitArray $bits,  $offset = 0,  $size = null)

Create a new BitArray using a slice

Since

1.1.0

param $bits:

A BitArray to get the slice

param $offset:

If offset is non-negative, the slice will start at that offset in the bits argument. If offset is negative, the slice will start from the end of the bits argument.

param $size:

If size is given and is positive, then the slice will have up to that many elements in it. If the bits argument is shorter than the size, then only the available elements will be present. If size is given and is negative then the slice will stop that many elements from the end of the bits argument. If it is omitted, then the slice will have everything from offset up until the end of the bits argument.

return:

BitArray A new BitArray

static chdemko\BitArray\BitArray::fromConcat(BitArray $bits1, BitArray $bits2)

Create a new BitArray using the concat operation

Since

1.1.0

param $bits1:

A BitArray

param $bits2:

A BitArray

return:

BitArray A new BitArray