prioq
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Prioq - TS priority queue

TypeScript priority queue implementation based on Wim Jongeneel's priority queues article.

Usage

import { priorityQueue } from "prioq";

// Any type
type Item = string;

const q = priorityQueue<Item>();

// Second argument is priority - lower is higher priority
q.insert("foo", 1);
q.insert("bar", 2);
q.insert("baz", 0.5);

q.peek(); // 'baz'
q.size(); // 3
q.isEmpty(); // false

q.pop(); // 'baz'
q.pop(); // 'foo'
q.pop(); // 'bar'

q.peek(); // null
q.size(); // 0
q.isEmpty(); // true

Credit

Readme

Keywords

none

Package Sidebar

Install

npm i prioq

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

9.31 kB

Total Files

9

Last publish

Collaborators

  • will.bamford