Class RandomSelector<Type>

A class for randomly selecting elements from a given list. This class assumes an equal distribution for all elements of the list.

Type Parameters

  • Type

Constructors

Accessors

  • get size(): number
  • Get the number of elements in the _elements list.

    Returns number

Methods

  • Selects random element from _elements.
    This method assumes an equal distribution for all elements of the list.
    If _elements is empty, the function will return undefined.

    Returns undefined | Type

  • Selects random element from _elements, then removes that element from the list.
    This method assumes an equal distribution for all elements of the list.
    If _elements is empty, the function will return undefined.

    Returns undefined | Type