Rush StackShopBlogEvents
Skip to main content

Home > @rushstack/node-core-library > MinimumHeap

MinimumHeap class

Implements a standard heap data structure for items of type T and a custom comparator. The root will always be the minimum value as determined by the comparator.

Signature:

export declare class MinimumHeap<T> 

Constructors

Constructor

Modifiers

Description

(constructor)(comparator)

Constructs a new MinimumHeap instance.

Properties

Property

Modifiers

Type

Description

size

readonly

number

Returns the number of items in the heap.

Methods

Method

Modifiers

Description

peek()

Retrieves the root item from the heap without removing it.

poll()

Retrieves and removes the root item from the heap. The next smallest item will become the new root.

push(item)

Pushes an item into the heap.