0.0.1 • Published 8 years ago

updatable-priority-queue v0.0.1

Weekly downloads
14
License
MIT
Repository
github
Last release
8 years ago

updatable-priority-queue

A generic priority queue implementation based on a binary heap, with an efficient updateKey operation.

It was made first to support the pathfinding algorithms of my jKstra graph library, but it can probably serves other purposes.

$> npm install updatable-priority-queue

API

PropertyTypeDescription
countIntegerNumber of items stored in the queue.
MethodReturnsDescription
insert(item, key)VertexAdds an item to the queue, with a key used as sorting value.
pop(){item, key}Removes and returns the first item of the queue, with its associated key, or null if the queue is empty.
peek(){item, key}Reads the first item of the queue, with its associated key, without removing it, or null if the queue is empty.
updateKey(item, newKey)-Updates the key associated with an element.