Options
All
  • Public
  • Public/Protected
  • All
Menu

A Bucket is a container of a fixed number of values, used in various bloom filters.

author

Thomas Minier

Type Parameters

  • T

Hierarchy

  • default

Index

Properties

_elements: (null | T)[]
_length: number
_size: number

Methods

  • add(element: null | T): boolean
  • Try to add an element to the bucket

    Parameters

    • element: null | T

      The element to add in the bucket

    Returns boolean

    True if the insertion is a success, False if the bucket is full

  • at(index: number): null | T
  • Get the element at the given index in the bucket

    Parameters

    • index: number

      The index to access

    Returns null | T

    The element at the given index

  • Test if two buckets are equals: they have the same size, length and content

    Parameters

    Returns boolean

    True if the two buckets are equals, False otherwise

  • has(element: T): boolean
  • Test an element for membership

    Parameters

    • element: T

      The element to look for in the bucket

    Returns boolean

    True is the element is in the bucket, otherwise False

  • isFree(): boolean
  • Test if the bucket has any space available

    Returns boolean

    True if te bucket has any space available, False if if its full

  • nextEmptySlot(): number
  • Get the index of the first empty slot in the bucket

    Returns number

    The index of the first empty slot, or -1 if the bucket is full

  • remove(element: T): boolean
  • Try to remove an element from the bucket

    Parameters

    • element: T

      The element to remove from the bucket

    Returns boolean

    True if the element has been successfully removed, False if it was not in the bucket

  • set(index: number, element: null | T): void
  • Set an element at the given index in the bucket

    Parameters

    • index: number

      The index at where the element should be inserted

    • element: null | T

      The element to insert

    Returns void

  • swap(index: number, element: T): null | T
  • Swap an element of the bucket with a given index and element, then return the replaced element

    Parameters

    • index: number

      The index at where the element should be inserted

    • element: T

      The element to be inserted

    Returns null | T

    The element that have been swapped with the parameter

  • swapRandom(element: T, random?: (() => number)): null | T
  • Randomly swap an element of the bucket with a given element, then return the replaced element

    Parameters

    • element: T

      The element to be inserted

    • random: (() => number) = Math.random

      Factory function used to generate random function

        • (): number
        • Returns number

    Returns null | T

    The element that have been swapped with the parameter

  • unset(index: number): void
  • Unset the element at the given index

    Parameters

    • index: number

      The index of the element that should be unset

    Returns void

Constructors

Accessors

  • get length(): number
  • get size(): number

Generated using TypeDoc