@darkblue_azurite/priority-queue

    1.0.7 • Public • Published

    Priority Queue

    Build Status dependencies Status npm version

    A priority queue implemented with a binary heap

    Installation

    For node js:

    npm install --save @darkblue_azurite/priority-queue
    

    then require it:

    var PriorityQueue = require("@darkblue_azurite/priority-queue");

    To use the library directly in the browser, copy the priority-queue.js file from the lib directory into your project and include it in your webpage. priority-queue.min.js provides you with a minified version. The files in the lib directory are also transpiled to es5.

    <script type="text/javascript" src="./priority-queue.js"></script>
    <script type="text/javascript">
      var queue = new PriorityQueue(); // available as a global
    </script> 

    Example Usage

    var tasks = [
      { task: "Wash the Dishes", priority: 5 },
      { task: "Clean the Bedroom", priority: 3 },
      { task: "Feed the Cat", priority: 1 },
      { task: "Do Groccery Shopping", priority: 8 }
    ];
     
    var queue = new PriorityQueue(tasks, function(t1, t2) {
      return t1.priority - t2.priority;
    });
     
    queue.size(); // 4
    queue.dequeue(); // { task: "Feed the Cat", priority: 1 }
    queue.enqueue({ task: "Go to the Gym", priority: 2 });

    Documentation

    Install

    npm i @darkblue_azurite/priority-queue

    DownloadsWeekly Downloads

    14

    Version

    1.0.7

    License

    MIT

    Unpacked Size

    35.6 kB

    Total Files

    12

    Last publish

    Collaborators

    • avatar