https://github.com/bbecquet/updatable-priority-queue
A priority queue implementation based on a binary heap, with an efficient update-key operation
https://github.com/bbecquet/updatable-priority-queue
Last synced: about 6 hours ago
JSON representation
A priority queue implementation based on a binary heap, with an efficient update-key operation
- Host: GitHub
- URL: https://github.com/bbecquet/updatable-priority-queue
- Owner: bbecquet
- Created: 2016-04-25T20:22:09.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-04-26T12:10:24.000Z (about 10 years ago)
- Last Synced: 2025-10-14T03:08:45.337Z (8 months ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
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](https://github.com/bbecquet/jKstra) graph library, but it can probably serve other purposes.
```bash
$> 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.