Skip to content

A priority queue implementation based on a binary heap, with an efficient update-key operation

Notifications You must be signed in to change notification settings

bbecquet/updatable-priority-queue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 serve other purposes.

$> npm install updatable-priority-queue

API

Property Type Description
count Integer Number of items stored in the queue.
Method Returns Description
insert(item, key) - Adds 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.

About

A priority queue implementation based on a binary heap, with an efficient update-key operation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published