Options
All
  • Public
  • Public/Protected
  • All
Menu

This implementation uses a binary heap. The enqueue and dequeue operations take logarithmic amortized time. The peek, size, and is-empty operations take constant time. Construction takes time proportional to the specified capacity or the number of items used to initialize the data structure.

iterator operation takes time proportional to the current size or the queue.

For additional documentation, see Section 2.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

Type parameters

  • E

    the generic type of key on this priority queue

Hierarchy

Implements

Index

Constructors

constructor

  • Construct priority queue.

    Parameters

    • comparator: Comparator<E>

      comparator for the queue elements.

    • Default value maxPQ: boolean = true

      true if this queue should be MaxPriorityQueue, and false if this queue should be MinPriorityQueue. Default value is true.

    • Default value keys: E[] = []

      elements to put in this queue. Default value is empty array.

    Returns PriorityQueue

Properties

Private comparator

comparator: Comparator<E>

comparator for the queue elements.

Private inOrder

inOrder: function

Type declaration

    • (i: number, j: number): boolean
    • Parameters

      • i: number
      • j: number

      Returns boolean

Private maxPQ

maxPQ: boolean

true if this queue should be MaxPriorityQueue, and false if this queue should be MinPriorityQueue. Default value is true.

Private n

n: number = 0

Private pq

pq: E[] = [undefined as any]

Methods

asCollection

dequeue

  • dequeue(): E

enqueue

  • enqueue(e: E): Queue<E>

every

  • every(p: function): boolean

Private exch

  • exch(i: number, j: number): void

filter

find

  • find(p: function): E | undefined

forEach

  • forEach(f: function): void

Private greaterInOrder

  • greaterInOrder(i: number, j: number): boolean

isEmpty

  • isEmpty(): boolean

iterator

Private lessInOrder

  • lessInOrder(i: number, j: number): boolean

map

peek

  • peek(): E

reduce

  • reduce<A>(r: function, initialValue: A): A

Private sink

  • sink(k: number): void

size

  • size(): number

some

  • some(p: function): boolean

Private swim

  • swim(k: number): void

toString

  • toString(): string

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc