Options
All
  • Public
  • Public/Protected
  • All
Menu

A MinHeap stores items sorted by ascending frequency

author

Thomas Minier

Hierarchy

  • MinHeap

Index

Properties

_content: HeapElement[]

Methods

  • Add a new element to the heap and keep items sorted by ascending frequency

    Parameters

    Returns void

  • clear(): void
  • Access an item at a given index

    Parameters

    • index: number

      Index of the item

    Returns undefined | HeapElement

    The item or undefined if the index is out of the array

  • indexOf(value: string): number
  • Get the index of an element by its value

    Parameters

    • value: string

      Value of the element to search for

    Returns number

    Index of the element or -1 if it is not in the heap

  • Remove and returns the element with the smallest frequency in the heap

    Returns undefined | HeapElement

    The element with the smallest frequency in the heap

  • remove(index: number): void
  • Remove an item at a given index and keep items sorted by ascending frequency

    Parameters

    • index: number

      Index of the item to remove

    Returns void

Constructors

Accessors

  • get length(): number

Generated using TypeDoc