GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • algorithms-ts
  • Options
  • AbstractCollection
  • AbstractIterator
  • AdjacencyListDigraph
  • ArrayCollection
  • ArrayIterator
  • BreadthFirstDirectedPaths
  • DepthFirstDirectedPaths
  • DepthFirstOrderDFS
  • DigraphBFS
  • DigraphDFS
  • DirectedDFS
  • DirectedEulerianCycleDFS

This view

  • Original page
  • New address

GeezerVison is showing prishedko.github.io — PriorityQueue | algorithms-ts

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

  • AbstractCollection<E>
    • PriorityQueue

Implements

  • Collection<E>
  • Queue<E>

Index

Constructors

  • constructor

Properties

  • comparator
  • inOrder
  • maxPQ
  • n
  • pq

Methods

  • asCollection
  • dequeue
  • enqueue
  • every
  • exch
  • filter
  • find
  • forEach
  • greaterInOrder
  • isEmpty
  • iterator
  • lessInOrder
  • map
  • peek
  • reduce
  • sink
  • size
  • some
  • swim
  • toString

Constructors

constructor

  • new PriorityQueue(comparator: Comparator<E>, maxPQ?: boolean, keys?: E[]): PriorityQueue
    • Defined in containers/PriorityQueue.ts:24

    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>
  • Defined in containers/PriorityQueue.ts:33

comparator for the queue elements.

Private inOrder

inOrder: function
  • Defined in containers/PriorityQueue.ts:24

Type declaration

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

      • i: number
      • j: number

      Returns boolean

Private maxPQ

maxPQ: boolean
  • Defined in containers/PriorityQueue.ts:33

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

Private n

n: number = 0
  • Defined in containers/PriorityQueue.ts:23

Private pq

pq: E[] = [undefined as any]
  • Defined in containers/PriorityQueue.ts:22

Methods

asCollection

  • asCollection(): Collection<E>
  • Implementation of Queue.asCollection

    • Defined in containers/PriorityQueue.ts:84

    Returns Collection<E>

dequeue

  • dequeue(): E
  • Implementation of Queue.dequeue

    • Defined in containers/PriorityQueue.ts:73

    Returns E

enqueue

  • enqueue(e: E): Queue<E>
  • Implementation of Queue.enqueue

    • Defined in containers/PriorityQueue.ts:66

    Parameters

    • e: E

    Returns Queue<E>

every

  • every(p: function): boolean
  • Inherited from AbstractCollection.every

    • Defined in commons/AbstractCollection.ts:50

    Parameters

    • p: function
        • (e: E): boolean
        • Parameters

          • e: E

          Returns boolean

    Returns boolean

Private exch

  • exch(i: number, j: number): void
    • Defined in containers/PriorityQueue.ts:109

    Parameters

    • i: number
    • j: number

    Returns void

filter

  • filter(p: function): Collection<E>
  • Inherited from AbstractCollection.filter

    • Defined in commons/AbstractCollection.ts:13

    Parameters

    • p: function
        • (e: E): boolean
        • Parameters

          • e: E

          Returns boolean

    Returns Collection<E>

find

  • find(p: function): E | undefined
  • Inherited from AbstractCollection.find

    • Defined in commons/AbstractCollection.ts:46

    Parameters

    • p: function
        • (e: E): boolean
        • Parameters

          • e: E

          Returns boolean

    Returns E | undefined

forEach

  • forEach(f: function): void
  • Inherited from AbstractCollection.forEach

    • Defined in commons/AbstractCollection.ts:23

    Parameters

    • f: function
        • (e: E): void
        • Parameters

          • e: E

          Returns void

    Returns void

Private greaterInOrder

  • greaterInOrder(i: number, j: number): boolean
    • Defined in containers/PriorityQueue.ts:47

    Parameters

    • i: number
    • j: number

    Returns boolean

isEmpty

  • isEmpty(): boolean
  • Implementation of Queue.isEmpty

    • Defined in containers/PriorityQueue.ts:51

    Returns boolean

iterator

  • iterator(): CollectionIterator<E>
  • Implementation of Collection.iterator

    Overrides AbstractCollection.iterator

    • Defined in containers/PriorityQueue.ts:119

    Returns CollectionIterator<E>

Private lessInOrder

  • lessInOrder(i: number, j: number): boolean
    • Defined in containers/PriorityQueue.ts:43

    Parameters

    • i: number
    • j: number

    Returns boolean

map

  • map<T>(f: function): Collection<T>
  • Inherited from AbstractCollection.map

    • Defined in commons/AbstractCollection.ts:7

    Type parameters

    • T

    Parameters

    • f: function
        • (e: E): T
        • Parameters

          • e: E

          Returns T

    Returns Collection<T>

peek

  • peek(): E
  • Implementation of Queue.peek

    • Defined in containers/PriorityQueue.ts:59

    Returns E

reduce

  • reduce<A>(r: function, initialValue: A): A
  • Inherited from AbstractCollection.reduce

    • Defined in commons/AbstractCollection.ts:27

    Type parameters

    • A

    Parameters

    • r: function
        • (accumulator: A, currentElement: E): A
        • Parameters

          • accumulator: A
          • currentElement: E

          Returns A

    • initialValue: A

    Returns A

Private sink

  • sink(k: number): void
    • Defined in containers/PriorityQueue.ts:95

    Parameters

    • k: number

    Returns void

size

  • size(): number
  • Implementation of Queue.size

    Overrides AbstractCollection.size

    • Defined in containers/PriorityQueue.ts:55

    Returns number

some

  • some(p: function): boolean
  • Inherited from AbstractCollection.some

    • Defined in commons/AbstractCollection.ts:54

    Parameters

    • p: function
        • (e: E): boolean
        • Parameters

          • e: E

          Returns boolean

    Returns boolean

Private swim

  • swim(k: number): void
    • Defined in containers/PriorityQueue.ts:88

    Parameters

    • k: number

    Returns void

toString

  • toString(): string
  • Implementation of Queue.toString

    • Defined in containers/PriorityQueue.ts:115

    Returns string

Generated using TypeDoc

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.