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

ds-js-stl

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ds-js-stl

ds-kit is an NPM package provide ready to use famous data structures to JavaScript. It draws inspiration from the structured beauty of C++ STL.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by800%
Maintainers
1
Weekly downloads
 
Created
Source

Install

npm install ds-js-stl

Description

The Library provides ready to use famous data structures to JavaScript. It draws inspiration from the structured beauty of C++ STL.

  1. Stack
  2. Queue
  3. Deque
  4. LinkedList
  5. DoubleLinkedList
  6. PriorityQueue

Usage


import { Stack, Queue, PriorityQueue, DoubleLinkedList, LinkedList, Deque } from 'ds-js-stl/index.js';

const stack = new Stack();
stack.push(32);
stack.pop();
console.log(stack.top());
console.log(stack.size());
console.log(stack.isEmpty());

const queue = new Queue();
queue.enqueue(32);
console.log(queue.dequeue());
console.log(queue.isEmpty());
console.log(queue.size());
console.log(queue.front());
console.log(queue.back());

const deque = new Deque();
deque.push_back(32);
deque.push_front(33);
console.log(deque.pop_front());
console.log(deque.pop_back());
console.log(deque.size());
console.log(deque.isEmpty());


const linkedList = new LinkedList();
linkedList.insert(32);
linkedList.display();
console.log(linkedList.size());
console.log(linkedList.isEmpty());
const headLinkedList = linkedList.head();


const doubleLinkedList = new DoubleLinkedList();
doubleLinkedList.insert(32);
doubleLinkedList.display();
console.log(doubleLinkedList.size());
console.log(doubleLinkedList.isEmpty());
const headLinkedList = doubleLinkedList.head();
const tailLinkedList = doubleLinkedList.tail();

// For MaxHeap
const priorityQueue = new PriorityQueue();
priorityQueue.insert(32);
console.log(priorityQueue.remove());
console.log(priorityQueue.peek());

//For MinHeap
const minPriorityQueue = new PriorityQueue("minHeap");
priorityQueue.insert(32);
console.log(priorityQueue.remove());
console.log(priorityQueue.peek());


Author

Abhishek Adarsh Mishra

Gmail | Twitter | Linkedin | Github |

Keywords

FAQs

Package last updated on 04 Sep 2023

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