Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BitMask<T>

Bit Masker utility class.

Type parameters

  • T

Hierarchy

  • BitMask

Index

Constructors

constructor

  • new BitMask<T>(value?: number, bits?: T[]): BitMask<T>
  • Type parameters

    • T

    Parameters

    • value: number = 0

      The current value of the bit mask, defaults to 0

    • bits: T[] = ...

      The array of names to use e.g. ['canOpen', 'canClose']

    Returns BitMask<T>

Properties

bits

bits: T[]

value

value: number

The current value of the mask

Methods

_get

  • _get(bit: number): boolean

_set

  • _set(bit: number, value: boolean): void

asArray

  • asArray(): T[]

asIndexArray

  • asIndexArray(): number[]
  • Returns an array of indexes in the bits array that are currently true.

    Returns number[]

fromIndexArray

  • fromIndexArray(indexs: number[]): void
  • Sets all values in the mask to true if they are in the array and false if they are not.

    Parameters

    • indexs: number[]

      An array of indexes in the bits array that need to be true.1

    Returns void

get

  • get(name: T): boolean
  • Checks the given bit name for its boolean value.

    Parameters

    • name: T

      The name of the bit to check. e.g. canOpen

    Returns boolean

set

  • set(name: T, value: boolean): void
  • Sets the given bit to the supplied value.

    Parameters

    • name: T

      The name of the bit to set e.g. canClose

    • value: boolean

      The boolean value to set it to.

    Returns void

Generated using TypeDoc