# Class: Bits

A bitset, without size limitation, allows comparison via bitwise operators to other bit fields. Mostly for internal use.

# Hierarchy

# Table of contents

# Constructors

# Properties

# Methods

# Constructors

# constructor

• new Bits(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.

# Inherited from

ReadonlyBits.constructor

# Defined in

src/utils/Bits.ts:17 (opens new window)

# Properties

# data

• Protected data: Int32Array

# Inherited from

ReadonlyBits.data

# Defined in

src/utils/Bits.ts:10 (opens new window)

# Methods

# and

▸ and(other): Bits

Performs a logical AND of this target bit set with the argument bit set. This bit set is modified so that each bit in it has the value true if and only if it both initially had the value true and the corresponding bit in the bit set argument also had the value true.

# Parameters

Name Type Description
other ReadonlyBits The other instance.

# Returns

Bits

This for chaining.

# Defined in

src/utils/Bits.ts:282 (opens new window)


# andNot

▸ andNot(other): Bits

Clears all of the bits in this instance whose corresponding bit is set in the other instance.

# Parameters

Name Type Description
other ReadonlyBits The other instance.

# Returns

Bits

This for chaining.

# Defined in

src/utils/Bits.ts:303 (opens new window)


# clear

▸ clear(index): void

# Parameters

Name Type Description
index number The index of the bit to clear.

# Returns

void

# Defined in

src/utils/Bits.ts:263 (opens new window)


# clearAll

▸ clearAll(): void

Clears the entire bitset.

# Returns

void

# Defined in

src/utils/Bits.ts:270 (opens new window)


# 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.

# Inherited from

ReadonlyBits.containsAll

# 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.

# Inherited from

ReadonlyBits.equals

# Defined in

src/utils/Bits.ts:188 (opens new window)


# flip

▸ flip(index): void

# Parameters

Name Type Description
index number The index of the bit to flip.

# Returns

void

# Defined in

src/utils/Bits.ts:247 (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.

# Inherited from

ReadonlyBits.get

# Defined in

src/utils/Bits.ts:32 (opens new window)


# getAndClear

▸ getAndClear(index): boolean

Returns the bit at the given index and clears it in one go.

# Parameters

Name Type Description
index number The index of the bit.

# Returns

boolean

Whether the bit was set before invocation.

# Defined in

src/utils/Bits.ts:212 (opens new window)


# getAndSet

▸ getAndSet(index): boolean

Returns the bit at the given index and sets it in one go.

# Parameters

Name Type Description
index number The index of the bit.

# Returns

boolean

Whether the bit was set before invocation.

# Defined in

src/utils/Bits.ts:226 (opens new window)


# getData

▸ getData(): ReadonlyInt32Array

# Returns

ReadonlyInt32Array

A readonly version of the underlying data.

# Inherited from

ReadonlyBits.getData

# Defined in

src/utils/Bits.ts:24 (opens new window)


# getStringId

▸ getStringId(): string

# Returns

string

All numbers as string, comma separated.

# Inherited from

ReadonlyBits.getStringId

# 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.

# Inherited from

ReadonlyBits.intersects

# 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.

# Inherited from

ReadonlyBits.isEmpty

# 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.

# Inherited from

ReadonlyBits.length

# 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.

# Inherited from

ReadonlyBits.nextClearBit

# 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.

# Inherited from

ReadonlyBits.nextSetBit

# 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!

# Inherited from

ReadonlyBits.numBits

# Defined in

src/utils/Bits.ts:39 (opens new window)


# or

▸ or(other): Bits

Performs a logical OR of this instance with the other instance. This instance is modified so that a bit in it has the value true if and only if it either already had the value true or the corresponding bit in the other instance has the value true.

# Parameters

Name Type Description
other ReadonlyBits A bit set.

# Returns

Bits

This for chaining.

# Defined in

src/utils/Bits.ts:319 (opens new window)


# set

▸ set(index): void

# Parameters

Name Type Description
index number The index of the bit to set.

# Returns

void

# Defined in

src/utils/Bits.ts:235 (opens new window)


# setAll

▸ setAll(): void

Sets the entire bitset.

# Returns

void

# Defined in

src/utils/Bits.ts:242 (opens new window)


# usedWords

▸ usedWords(): number

# Returns

number

The minimal number of words to store all the bits.

# Inherited from

ReadonlyBits.usedWords

# Defined in

src/utils/Bits.ts:44 (opens new window)


# xor

▸ xor(other): Bits

Performs a logical XOR of this bit set with the bit set argument. This bit set is modified so that a bit in it has the value true if and only if one of the following statements holds:

  • The bit initially has the value true, and the corresponding bit in the argument has the value false.
  • The bit initially has the value false, and the corresponding bit in the argument has the value true.

# Parameters

Name Type Description
other ReadonlyBits The other instance.

# Returns

Bits

This for chaining.

# Defined in

src/utils/Bits.ts:345 (opens new window)