NGL@1.0.0-beta.7 Home Manual Reference Source Gallery
import BitArray from 'ngl/src/utils/bitarray.js'
public class | source

BitArray

Bit array

Based heavily on https://github.com/lemire/FastBitSet.js which is licensed under the Apache License, Version 2.0.

Constructor Summary

Public Constructor
public

constructor(length: Integer, setAll: Boolean)

Member Summary

Public Members
public
Private Members
private

Method Summary

Public Methods
public

Set value at index to false

public

Clear all bits of the array

public

clearBits(arguments: ...Integer): Boolean

Clear bits at all given indices

public

Clear bits of the given range

public

Clone this object

public

difference(otherBitarray: BitArray): BitArray

Calculate difference betwen this and another bit array.

public

Flip value at index

public

Flip all the values in the array

public

forEach(callback: function(index: Integer, i: Integer)): undefined

Iterate over all set bits in the array

public

get(index: Integer): Boolean

Get value at index

public

Calculate the number of bits in common betwen this and another bit array.

public

How many set bits?

public

intersection(otherBitarray: BitArray): BitArray

Calculate intersection betwen this and another bit array.

public

intersects(otherBitarray: BitArray): Boolean

Test if there is any intersection betwen this and another bit array.

public

Test if all bits in the array are clear

public

Test if all bits in the array are set

public

isClear(arguments: ...Integer): Boolean

Test if bits at all given indices are clear

public

isEqualTo(otherBitarray: BitArray): Boolean

Test if two BitArrays are identical in all their values

public

Test if bits in given range are clear

public

Test if bits in given range are set

public

isSet(arguments: ...Integer): Boolean

Test if bits at all given indices are set

public

Calculate intersection betwen this and another bit array.

public

set(index: Integer): undefined

Set value at index to true

public

Set all bits of the array

public

setBits(arguments: ...Integer): Boolean

Set bits at all given indices

public

setRange(start: Integer, end: Integer): BitArray

Set bits of the given range

public

Get an array with the set bits

public
public
public

union(otherBitarray: BitArray): BitArray

Calculate union betwen this and another bit array.

Private Methods
private
private

Public Constructors

public constructor(length: Integer, setAll: Boolean) source

Params:

NameTypeAttributeDescription
length Integer

array length

setAll Boolean
  • optional

initialize with true

Public Members

public length source

Private Members

private _words source

Public Methods

public clear(index: Integer): undefined source

Set value at index to false

Params:

NameTypeAttributeDescription
index Integer

the index

Return:

undefined

public clearAll(): BitArray source

Clear all bits of the array

Return:

BitArray

this object

public clearBits(arguments: ...Integer): Boolean source

Clear bits at all given indices

Params:

NameTypeAttributeDescription
arguments ...Integer

indices

Return:

Boolean

this object

public clearRange(start: Integer, end: Integer): BitArray source

Clear bits of the given range

Params:

NameTypeAttributeDescription
start Integer

start index

end Integer

end index

Return:

BitArray

this object

public clone(): BitArray source

Clone this object

Return:

BitArray

the cloned object

public difference(otherBitarray: BitArray): BitArray source

Calculate difference betwen this and another bit array. Store result in this object.

Params:

NameTypeAttributeDescription
otherBitarray BitArray

the other bit array

Return:

BitArray

this object

public flip(index: Integer): undefined source

Flip value at index

Params:

NameTypeAttributeDescription
index Integer

the index

Return:

undefined

public flipAll(): BitArray source

Flip all the values in the array

Return:

BitArray

this object

public forEach(callback: function(index: Integer, i: Integer)): undefined source

Iterate over all set bits in the array

Params:

NameTypeAttributeDescription
callback function(index: Integer, i: Integer)

the callback

Return:

undefined

public get(index: Integer): Boolean source

Get value at index

Params:

NameTypeAttributeDescription
index Integer

the index

Return:

Boolean

value

public getIntersectionSize(otherBitarray: BitArray): Integer source

Calculate the number of bits in common betwen this and another bit array.

Params:

NameTypeAttributeDescription
otherBitarray BitArray

the other bit array

Return:

Integer

size

public getSize(): Integer source

How many set bits?

Return:

Integer

number of set bits

public intersection(otherBitarray: BitArray): BitArray source

Calculate intersection betwen this and another bit array. Store result in this object.

Params:

NameTypeAttributeDescription
otherBitarray BitArray

the other bit array

Return:

BitArray

this object

public intersects(otherBitarray: BitArray): Boolean source

Test if there is any intersection betwen this and another bit array.

Params:

NameTypeAttributeDescription
otherBitarray BitArray

the other bit array

Return:

Boolean

test result

public isAllClear(): Boolean source

Test if all bits in the array are clear

Return:

Boolean

test result

public isAllSet(): Boolean source

Test if all bits in the array are set

Return:

Boolean

test result

public isClear(arguments: ...Integer): Boolean source

Test if bits at all given indices are clear

Params:

NameTypeAttributeDescription
arguments ...Integer

indices

Return:

Boolean

test result

public isEqualTo(otherBitarray: BitArray): Boolean source

Test if two BitArrays are identical in all their values

Params:

NameTypeAttributeDescription
otherBitarray BitArray

the other BitArray

Return:

Boolean

test result

public isRangeClear(start: Integer, end: Integer): BitArray source

Test if bits in given range are clear

Params:

NameTypeAttributeDescription
start Integer

start index

end Integer

end index

Return:

BitArray

this object

public isRangeSet(start: Integer, end: Integer): BitArray source

Test if bits in given range are set

Params:

NameTypeAttributeDescription
start Integer

start index

end Integer

end index

Return:

BitArray

this object

public isSet(arguments: ...Integer): Boolean source

Test if bits at all given indices are set

Params:

NameTypeAttributeDescription
arguments ...Integer

indices

Return:

Boolean

test result

public makeIntersection(otherBitarray: BitArray): BitArray source

Calculate intersection betwen this and another bit array. Store result in a new bit array.

Params:

NameTypeAttributeDescription
otherBitarray BitArray

the other bit array

Return:

BitArray

the new bit array

public set(index: Integer): undefined source

Set value at index to true

Params:

NameTypeAttributeDescription
index Integer

the index

Return:

undefined

public setAll(): BitArray source

Set all bits of the array

Return:

BitArray

this object

public setBits(arguments: ...Integer): Boolean source

Set bits at all given indices

Params:

NameTypeAttributeDescription
arguments ...Integer

indices

Return:

Boolean

this object

public setRange(start: Integer, end: Integer): BitArray source

Set bits of the given range

Params:

NameTypeAttributeDescription
start Integer

start index

end Integer

end index

Return:

BitArray

this object

public toArray(): Array source

Get an array with the set bits

Return:

Array

bit indices

public toSeleString() source

public toString() source

public union(otherBitarray: BitArray): BitArray source

Calculate union betwen this and another bit array. Store result in this object.

Params:

NameTypeAttributeDescription
otherBitarray BitArray

the other bit array

Return:

BitArray

this object

Private Methods

private _assignRange() source

private _isRangeValue() source