BitArray
Defined in: js-api/src/u2core/bit-array.ts:6
A pure-JS bit array with the BitSet vocabulary: LSB-first Uint32Array words, bit i at
words[i >>> 5] & (1 << (i & 31)), and the bits of the last word beyond length always zero — so
equals is a word compare and DG.BitSet.fromBitArray reads the words as they are.
Constructors
Constructor
new BitArray(
length,fill?):BitArray
Defined in: js-api/src/u2core/bit-array.ts:10
Parameters
| Parameter | Type |
|---|---|
length | number |
fill? | boolean |
Returns
BitArray
Constructor
new BitArray(
words,length):BitArray
Defined in: js-api/src/u2core/bit-array.ts:12
Adopts words (no copy); they must hold at least lengthInInts words.
Parameters
| Parameter | Type |
|---|---|
words | Uint32Array |
length | number |
Returns
BitArray
Accessors
allFalse
Get Signature
get allFalse():
boolean
Defined in: js-api/src/u2core/bit-array.ts:134
Returns
boolean
allTrue
Get Signature
get allTrue():
boolean
Defined in: js-api/src/u2core/bit-array.ts:133
Returns
boolean
anyFalse
Get Signature
get anyFalse():
boolean
Defined in: js-api/src/u2core/bit-array.ts:132
Returns
boolean
anyTrue
Get Signature
get anyTrue():
boolean
Defined in: js-api/src/u2core/bit-array.ts:131
Returns
boolean
falseCount
Get Signature
get falseCount():
number
Defined in: js-api/src/u2core/bit-array.ts:127
Returns
number
length
Get Signature
get length():
number
Defined in: js-api/src/u2core/bit-array.ts:97
Returns
number
lengthInInts
Get Signature
get lengthInInts():
number
Defined in: js-api/src/u2core/bit-array.ts:101
Returns
number
trueCount
Get Signature
get trueCount():
number
Defined in: js-api/src/u2core/bit-array.ts:123
Returns
number
Methods
and()
and(
other):this
Defined in: js-api/src/u2core/bit-array.ts:182
Bitwise AND with other (same length) in place.
Parameters
| Parameter | Type |
|---|---|
other | BitArray |
Returns
this
andNot()
andNot(
other):this
Defined in: js-api/src/u2core/bit-array.ts:206
Clears the bits set in other (same length) in place.
Parameters
| Parameter | Type |
|---|---|
other | BitArray |
Returns
this
andWithCountBits()
andWithCountBits(
other,value?):number
Defined in: js-api/src/u2core/bit-array.ts:214
The number of bits equal to value in this AND other, without modifying either.
Parameters
| Parameter | Type | Default value |
|---|---|---|
other | BitArray | undefined |
value | boolean | true |
Returns
number
clone()
clone():
BitArray
Defined in: js-api/src/u2core/bit-array.ts:136
Returns
BitArray
copyFrom()
copyFrom(
other):this
Defined in: js-api/src/u2core/bit-array.ts:141
Copies the bits of other, which must have the same length.
Parameters
| Parameter | Type |
|---|---|
other | BitArray |
Returns
this
equals()
equals(
other):boolean
Defined in: js-api/src/u2core/bit-array.ts:148
Same length and same bits.
Parameters
| Parameter | Type |
|---|---|
other | BitArray |
Returns
boolean
findNext()
findNext(
i,x?):number
Defined in: js-api/src/u2core/bit-array.ts:227
The first index after i (pass -1 to start from the beginning) whose bit is x, or -1.
Parameters
| Parameter | Type | Default value |
|---|---|---|
i | number | undefined |
x | boolean | true |
Returns
number
findPrev()
findPrev(
i,x?):number
Defined in: js-api/src/u2core/bit-array.ts:245
The last index before i (pass -1 to start from the end) whose bit is x, or -1.
Parameters
| Parameter | Type | Default value |
|---|---|---|
i | number | undefined |
x | boolean | true |
Returns
number
get()
get(
i):boolean
Defined in: js-api/src/u2core/bit-array.ts:111
Gets the i-th bit; unchecked.
Parameters
| Parameter | Type |
|---|---|
i | number |
Returns
boolean
getBuffer()
getBuffer():
Uint32Array
Defined in: js-api/src/u2core/bit-array.ts:106
The live words; a direct write must keep the bits beyond length zero.
Returns
Uint32Array
getRange()
getRange(
from,to):BitArray
Defined in: js-api/src/u2core/bit-array.ts:333
A copy of the bits in [from, to).
Parameters
| Parameter | Type |
|---|---|
from | number |
to | number |
Returns
BitArray
getSelectedIndexes()
getSelectedIndexes():
Int32Array
Defined in: js-api/src/u2core/bit-array.ts:261
Indexes of all set bits.
Returns
Int32Array
init()
init(
f):this
Defined in: js-api/src/u2core/bit-array.ts:161
Sets the i-th bit to f(i) for every i.
Parameters
| Parameter | Type |
|---|---|
f | BitPredicate |
Returns
this
invert()
invert():
this
Defined in: js-api/src/u2core/bit-array.ts:175
Returns
this
or()
or(
other):this
Defined in: js-api/src/u2core/bit-array.ts:190
Bitwise OR with other (same length) in place.
Parameters
| Parameter | Type |
|---|---|
other | BitArray |
Returns
this
removeAt()
removeAt(
pos,n?):void
Defined in: js-api/src/u2core/bit-array.ts:294
Removes n bits starting at pos, shifting the following bits down.
Parameters
| Parameter | Type | Default value |
|---|---|---|
pos | number | undefined |
n | number | 1 |
Returns
void
set()
set(
i,x):void
Defined in: js-api/src/u2core/bit-array.ts:116
Sets the i-th bit; unchecked.
Parameters
| Parameter | Type |
|---|---|
i | number |
x | boolean |
Returns
void
setAll()
setAll(
x):this
Defined in: js-api/src/u2core/bit-array.ts:170
Parameters
| Parameter | Type |
|---|---|
x | boolean |
Returns
this
setLength()
setLength(
n):void
Defined in: js-api/src/u2core/bit-array.ts:280
Resizes to n bits, the added ones false; reallocates to exactly the words needed.
Parameters
| Parameter | Type |
|---|---|
n | number |
Returns
void
setRange()
setRange(
from,to,x):this
Defined in: js-api/src/u2core/bit-array.ts:304
Sets the bits in [from, to) to x.
Parameters
| Parameter | Type |
|---|---|
from | number |
to | number |
x | boolean |
Returns
this
toBinaryString()
toBinaryString():
string
Defined in: js-api/src/u2core/bit-array.ts:356
Returns
string
toString()
toString():
string
Defined in: js-api/src/u2core/bit-array.ts:349
The bits as a string of '0' and '1' characters, like '0110'.
Returns
string
trueIndexes()
trueIndexes():
IterableIterator<number>
Defined in: js-api/src/u2core/bit-array.ts:272
Iterates the indexes of the set bits in ascending order.
Returns
IterableIterator<number>
xor()
xor(
other):this
Defined in: js-api/src/u2core/bit-array.ts:198
Bitwise XOR with other (same length) in place.
Parameters
| Parameter | Type |
|---|---|
other | BitArray |
Returns
this
create()
staticcreate(length,f?):BitArray
Defined in: js-api/src/u2core/bit-array.ts:64
A bit array of length bits, the i-th one f(i) when f is given.
Parameters
| Parameter | Type |
|---|---|
length | number |
f? | BitPredicate | null |
Returns
BitArray
fromBytes()
staticfromBytes(buffer,bitLength?):BitArray
Defined in: js-api/src/u2core/bit-array.ts:75
A copy of the little-endian bytes; bitLength defaults to all of them.
Parameters
| Parameter | Type |
|---|---|
buffer | ArrayBuffer | ArrayBufferView<ArrayBufferLike> |
bitLength? | number |
Returns
BitArray
fromString()
staticfromString(zerosOnes):BitArray
Defined in: js-api/src/u2core/bit-array.ts:70
From a string of '0' and '1' characters, like '0110'.
Parameters
| Parameter | Type |
|---|---|
zerosOnes | string |
Returns
BitArray
fromUint32Array()
staticfromUint32Array(length,words):BitArray
Defined in: js-api/src/u2core/bit-array.ts:93
Adopts words (no copy), like the constructor.
Parameters
| Parameter | Type |
|---|---|
length | number |
words | Uint32Array |
Returns
BitArray