# Class: ReadonlyBits
A bitset, without size limitation, allows comparison via bitwise operators to other bit fields. Mostly for internal use.
# Hierarchy
ReadonlyBits
↳
Bits
# Table of contents
# Constructors
# Properties
# Methods
- containsAll
- equals
- get
- getData
- getStringId
- intersects
- isEmpty
- length
- nextClearBit
- nextSetBit
- numBits
- usedWords
# Constructors
# constructor
• new ReadonlyBits(nbits?
)
Creates a bit set whose initial size is large enough to explicitly represent bits with indices in the range 0 through nbits-1.
# Parameters
Name | Type | Default value | Description |
---|---|---|---|
nbits | number | 64 | The initial size of the bit set. |
# Defined in
src/utils/Bits.ts:17 (opens new window)
# Properties
# data
• Protected
data: Int32Array
# Defined in
src/utils/Bits.ts:10 (opens new window)
# Methods
# containsAll
▸ containsAll(other
): boolean
Returns true if this instance is a super set of the other instance, i.e. it has all bits set to true that are also set to true in the other instance.
# Parameters
Name | Type | Description |
---|---|---|
other | ReadonlyBits | The other instance. |
# Returns
boolean
True if this bit set is a super set of the specified set.
# Defined in
src/utils/Bits.ts:162 (opens new window)
# equals
▸ equals(other
): boolean
Compare with another set of bits.
# Parameters
Name | Type | Description |
---|---|---|
other | ReadonlyBits | The bits to compare with. |
# Returns
boolean
True if all bits match.
# Defined in
src/utils/Bits.ts:188 (opens new window)
# get
▸ get(index
): boolean
# Parameters
Name | Type | Description |
---|---|---|
index | number | The index of the bit. |
# Returns
boolean
Whether the bit is set.
# Defined in
src/utils/Bits.ts:32 (opens new window)
# getData
▸ getData(): ReadonlyInt32Array
# Returns
A readonly version of the underlying data.
# Defined in
src/utils/Bits.ts:24 (opens new window)
# getStringId
▸ getStringId(): string
# Returns
string
All numbers as string, comma separated.
# Defined in
src/utils/Bits.ts:178 (opens new window)
# intersects
▸ intersects(other
): boolean
Returns true if the other instance has any bits set to true that are also set to true in this instance.
# Parameters
Name | Type | Description |
---|---|---|
other | ReadonlyBits | The other instance. |
# Returns
boolean
True if this bit set intersects the specified bit set.
# Defined in
src/utils/Bits.ts:145 (opens new window)
# isEmpty
▸ isEmpty(): boolean
# Returns
boolean
True if this bitset contains no bits that are set to true.
# Defined in
src/utils/Bits.ts:73 (opens new window)
# length
▸ length(): number
Returns the "logical size" of this bitset: The index of the highest set bit in the bitset plus one. Returns zero if the bitset contains no set bits.
# Returns
number
The logical size of this bitset.
# Defined in
src/utils/Bits.ts:58 (opens new window)
# nextClearBit
▸ nextClearBit(fromIndex
): number
Returns the index of the first bit that is set to false that occurs on or after the specified starting index.
# Parameters
Name | Type | Description |
---|---|---|
fromIndex | number | The index to start looking. |
# Returns
number
>= 0 if a falsy bit was found, -1 otherwise.
# Defined in
src/utils/Bits.ts:119 (opens new window)
# nextSetBit
▸ nextSetBit(fromIndex
): number
Returns the index of the first bit that is set to true that occurs on or after the specified starting index.
# Parameters
Name | Type | Description |
---|---|---|
fromIndex | number | The index to start looking. |
# Returns
number
>= 0 if a truthy bit was found, -1 otherwise.
# Defined in
src/utils/Bits.ts:89 (opens new window)
# numBits
▸ numBits(): number
# Returns
number
The number of bits currently stored, not the highest set bit!
# Defined in
src/utils/Bits.ts:39 (opens new window)
# usedWords
▸ usedWords(): number
# Returns
number
The minimal number of words to store all the bits.