Skip to content

node package for top and bottom plus lifo/ fifo queues, stack, priority queues, double ended queues, circular queues, wait queues, and semaphore queues implementation

License

Notifications You must be signed in to change notification settings

ganeshkbhat/queues.js

Repository files navigation

queues.js

node package for top and bottom plus lifo/ fifo queues, stack, priority queues, double ended queues, circular queues, wait queues (TODO), and semaphore queues (TODO) implementation

Find the demos in the demos folder

APIs queues.js

Commonjs Code

var queues = require("queues.js");

var Queue = require("queues.js").Queue;
var QueueFifo = require("queues.js").QueueFifo;
var QueueLifo = require("queues.js").QueueLifo;

var queue = new Queue();
var fifo = new QueueFifo();
var lifo = new QueueLifo();

ESM Code

import { default as queues, QueueLifo, QueueFifo } as "queues.js";

var fifo = new QueueFifo();
var lifo = new QueueLifo();

ESM or Commonjs Code

var queues = import("queues.js");
var QueueFifo = import("queues.js").QueueFifo;
var QueueLifo = import("queues.js").QueueLifo;

var fifo = new QueueFifo();
var lifo = new QueueLifo();

Bases used

  • Queue - Persistent Queue (stores the queue value at its place - uses a offset)
  • QueueLowFootprint - Non-Persistent Queue (releases the queue value from its place permanently - use value once)
  • All LowFootprint names classes / functions are non-persistent queues

Queue Types

Queue (includes all Base methods)


const { Queue, QueueLowFootprint, QueueLifo, QueueFifo, QueueLowFootprintLifo, QueueLowFootprintFifo, AsyncQueue, AsyncQueueLowFootprint } = require("queues.js");

Queue Bottom Fifo

Queue Bottom Lifo

QueueTop (includes all Base methods)


const { QueueTop, QueueTopLowFootprint, QueueTopLifo, QueueTopFifo, QueueTopLowFootprintLifo, QueueTopLowFootprintFifo, AsyncQueueTop, AsyncQueueTopLowFootprint } = require("queues.js");

Queue Top Fifo

Queue Top Lifo

Stack (includes all Base methods)


const { Stack, StackLowFootprint, AsyncStack, AsyncStackLowFootprint } = require("queues.js");

Stack

Double - Denqueue (includes all Base methods)


const { DoubleEnded, DoubleEndedLowFootprint, AsyncDoubleEnded, AsyncDoubleEndedLowFootprint } = require("queues.js");

Double Ended Queue

Semaphore (includes all Base methods)

In development


const { Semaphore } = require("queues.js");

WaitQueue (includes all Base methods)

In development


const { WaitQueue } = require("queues.js");

Priority Queue (includes all Base methods)


const { Priority, PriorityLowFootprint, AsyncPriority, AsyncPriorityLowFootprint } = require("queues.js");

Priority Queue

Circular Queue (includes all Base methods)

In development - Currently Testing


const { Circular, AsyncCircular } = require("queues.js");

Circular Queue

FIFO BOTTOM QUEUE IMPLEMENTATION

//
// FIFO BOTTOM QUEUE IMPLEMENTATION
// 
//   <==   [1,2,3,4]  <==
//

var queues = require("queues.js");
var QueueFifo = require("queues.js").QueueFifo;

var fifo = new QueueFifo();
fifo.enqueue(item);
fifo.add(item);
fifo.insert(item);
fifo.push(item);

fifo.dequeue();
fifo.shift();
fifo.remove();

LIFO BOTTOM QUEUE IMPLEMENTATION

//
// LIFO BOTTOM QUEUE IMPLEMENTATION
// 
//              <==
//   [1,2,3,4]  
//              ==>
//

var queues = require("queues.js");
var QueueLifo = require("queues.js").QueueLifo;

var lifo = new QueueLifo();
lifo.enqueue(item);
lifo.add(item);
lifo.push(item);
lifo.insert(item);

lifo.dequeue();
lifo.pop();
lifo.remove();

TODO

.todo In Development: Asynchronous Implementation, Semphores, Wait Queues

Contributions

Contributions, Feature Improvements, Bugs, and Issues are invited. raising an issue

License

MIT License

About

node package for top and bottom plus lifo/ fifo queues, stack, priority queues, double ended queues, circular queues, wait queues, and semaphore queues implementation

Resources

License

Stars

Watchers

Forks

Packages

No packages published