Options
All
  • Public
  • Public/Protected
  • All
Menu

A memory-efficient Boolean array. Contains just the minimal operations needed for our Bloom filter implementation.

author

David Leppik

Hierarchy

  • BitSet

Index

Methods

  • add(index: number): void
  • Set the bit to true

    Parameters

    • index: number

      position of the bit, zero-indexed

    Returns void

  • bitCount(): number
  • countBits(bits: number): number
  • Returns the number of true bits in the number

    bits

    an unsigned 8-bit number

    example
    BitSet.countBits(0) // returns 0
    BitSet.countBits(3) // returns 2

    Parameters

    • bits: number

    Returns number

  • equals(other: BitSet): boolean
  • export(): { content: string; size: number }
  • Returns a JSON-encodable object readable by import.

    Returns { content: string; size: number }

    • content: string
    • size: number
  • has(index: number): boolean
  • Returns the value of the bit at the given index

    Parameters

    • index: number

      position of the bit, zero-indexed

    Returns boolean

  • highBit(bits: number): number
  • Returns the index of the maximum bit in the number, or -1 for 0

    bits

    an unsigned 8-bit number

    @example
    BitSet.highBit(0) // returns -1
    BitSet.highBit(5) // returns 2

    Parameters

    • bits: number

    Returns number

  • import(data: { content: string; size: number }): BitSet
  • max(): number

Properties

array: Uint8Array
size: number

Constructors

  • new BitSet(size: number): BitSet
  • Constructor. All bits are initially set to false.

    Parameters

    • size: number

      the number of bits that can be stored. (This is NOT required to be a multiple of 8.)

    Returns BitSet

Generated using TypeDoc