mangabi-datastructures

1.0.0 • Public • Published

Mangabi Data Structures

Set of useful data structures used at Mangabi

Priority Queue

Usage

import { PriorityQueue } from 'mangabi-datastructures'
 
const q = Object.create(PriorityQueue)
q.append(1)
q.append(3)
q.append(2)
 
q.dequeue() // 3
q.dequeue() // 2
q.dequeue() // 1

Comparator

The default comparator sorts by the alphanumeric Object.toString() value, but a new comparator can be swapped in using q.comparator = ...

q.comparator = function(a, b) {
  return a.length < b.length
}

Readme

Keywords

Package Sidebar

Install

npm i mangabi-datastructures

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • mangabi