Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

namastey-circular-queue

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

namastey-circular-queue

An efficient JavaScript package for implementing and working with Circular Queue data structures.

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by400%
Maintainers
0
Weekly downloads
 
Created
Source

namastey-circular-queue

Description

namastey-circular-queue is a JavaScript package that implements the Circular Queue data structure with various important methods. A Circular Queue is a linear data structure that follows the FIFO (First In First Out) principle and connects the end of the queue back to the beginning, making it circular.

Features

  • enqueue(item): Adds an item to the end of the queue. Throws an error if the queue is full.
  • dequeue(): Removes and returns the item at the front of the queue. Throws an error if the queue is empty.
  • peek(): Returns the item at the front of the queue without removing it. Throws an error if the queue is empty.
  • isEmpty(): Checks if the queue is empty.
  • isFull(): Checks if the queue is full.
  • getSize(): Returns the current number of items in the queue.
  • printQueue(): Prints the queue, showing the elements and null for empty slots.

Installation

To install the package globally, use the following command:

npm install -g namastey-circular-queue

Examples

const CircularQueue = require('namastey-circular-queue');

const queue = new CircularQueue(5);

queue.enqueue(1);
queue.enqueue(2);
queue.enqueue(3);
queue.enqueue(4);
queue.enqueue(5);

console.log(queue.peek()); // Output: 1

queue.printQueue(); // Output: 1 2 3 4 5 

queue.dequeue();
console.log(queue.peek()); // Output: 2

queue.enqueue(6);
queue.printQueue(); // Output: 6 2 3 4 5

Keywords

FAQs

Package last updated on 27 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc