Perisistent Priority Queue implemented with Pairing Heaps for TS
Last updated 3 years ago by iskolbin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install tspersistentpriorityqueue 
SYNC missed versions from official npm registry.

Build Status license MIT Licence

Persistent priority queue

Persistent priority queue implemented with pairing heap. Implementation allows fast peek, enqueue, dequeue.

constructor(comparator = DEFAULT_COMPARATOR, arraylike?: [T,P][])

Creates new queue. By default uses comparator for minimal heap, i.e. item with the smallest priority will dequeue first. If arraylike is passed populate queue


Property returning size of the queue


Yields true if length is zero and false otherwise

enqueue(element: T, priority: P): PriorityQueue<T,P>

Enqueues element into the queue with specified priority. Returns new queue

dequeue(): PriorityQueue<T,P>

Dequeue element from queue and returns new queue. If queue is empty returns itself

first(): T | undefined

Returns element with the highest priority or undefined if the queue is empty

firstPriority(): P | undefined

Returns highest priority of the queue or undefined if the queue is empty

has(element: T): boolean

Returns true if the element is in the queue and false otherwise. This is slow O(n) method

clear(): boolean

If queue has items returns new empty queue otherwise returns itself

forEach( callback(element: T, priority: P, queue: PriorityQueue<T,P>), thisArg?: any )

Calls callback for each element and priority in the queue.

Current Tags

  • 0.2.5                                ...           latest (3 years ago)

3 Versions

  • 0.2.5                                ...           3 years ago
  • 0.2.4                                ...           3 years ago
  • 0.2.3                                ...           3 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 4
Dependencies (0)
Dev Dependencies (5)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |