Options
All
  • Public
  • Public/Protected
  • All
Menu

An object that can be used to efficiently store and manage the frequencies of the specified keys.

Type parameters

  • K: string | number

Hierarchy

  • AbstractCollection<[K, number]>
    • FrequencyTable

Index

Constructors

Accessors

  • get count(): number
  • get isEmpty(): boolean
  • get total(): number

Methods

  • [iterator](): Iterator<[K, number], any, undefined>
  • clear(): void
  • decrement(key: K): void
  • If the frequency of the specified key is positive, decreases it by 1. Otherwise (if it's 0), doesn't do anything.

    remarks

    Complexity:

    • Time complexity: O(1)
    • Space complexity: O(1)

    Parameters

    • key: K

      The key whose frequency to decrement.

    Returns void

  • frequencyOf(key: K): number
  • Retrieves the frequency of the specified key. Returns 0, if the key doesn't exist in the table.

    remarks

    Complexity:

    • Time complexity: O(1)
    • Space complexity: O(1)

    Parameters

    • key: K

      The key whose frequency to decrement.

    Returns number

    A non-negative integer indicating the frequency of the specified key.

  • increment(key: K): void
  • Increases the frequency of the specified key by 1.

    remarks

    Complexity:

    • Time complexity: O(1)
    • Space complexity: O(1)

    Parameters

    • key: K

      The key whose frequency to increment.

    Returns void

  • toArray(): [K, number][]
  • Converts the collection into a plain array.

    remarks

    Complexity:

    • Time complexity: O(N)
    • Space complexity: O(N)

    where:

    • N: number of items in the collection

    Returns [K, number][]

    A new array containing all the items in the collection.

Generated using TypeDoc