npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

datastructuresnpm

v4.0.0

Published

This is data structures module I am creating as a personal project.

Downloads

5

Readme

You can see the package here:

https://www.npmjs.com/package/datastructuresnpm

Data Structures Library

This is a library I created as a personal project, and as a convenience for myself and others. This library contains commonly used data structures such as:

  1. Stacks
  2. Queues
  3. Singly Linked Lists
  4. Doubly Linked Lists
  5. Binary Search Trees
  6. Hash Table

Example

Below you will find an example of how to bring in the module, and begin using it.

var dataStructures = require('datastructuresnpm');

var LL = new dataStructures.SinglyLinkedList();

LL.addNode(5);
LL.addNode(6);
LL.removeNode(6)

console.log(LL);

Below is how you can instantiate the different data structures currently available:

var dataStructures = require('datastructuresnpm');

var stack = new dataStructures.Stack();
var queue = new dataStructures.Queue();
var singlyLinkedList = new dataStructures.SinglyLinkedList();
var doublyLinkedList = new dataStructures.DoublyLinkedList();
var binaryTree = new dataStructures.BinarySearchTree();
var hashTable = new dataStructures.HashTable();

Methods

The methods for each data structure are as follows:

Stack

  1. pop() - removes and returns the top most element in the stack
  2. push(element) - pushes a new element on to the stack
  3. peek() - returns top most element in the stack but does not remove it
  4. sizeOf() - displays size of stack
  5. isEmpty() - console logs true or false depending on whether stack is empty or not
  6. printStack() - prints all the values in the stack

Queue

  1. enqueue(element) - adds an element to the queue
  2. dequeue() - removes and returns the first element in the queue
  3. front() - returns first element in the queue but does not remove it
  4. isEmpty() - console logs true or false depending on whether queue is empty or not
  5. sizeOf() - returns the size of the queue

Singly Linked List

  1. addNode(element) - adds a node to the linked list
  2. removeNode(element) - removes a specific node of from the linked list based on the value of the element it holds, e.g.(removeNode(5) will remove the node containing the number '5')
  3. insertNodeAt(element, index) - adds a node with an element of your choosing at the index you want (e.g. insertNodeAt(5,2) will insert a node containing the number 5 at index 2)
  4. removeNodeAt(index) - removes a node at specified index
  5. sizeOf() - returns the size of the linked list
  6. isEmpty() - console logs true or false depending on whether linked list is empty or not
  7. displayNode(index) - searches for the node at the specified index and displays the information

Doubly Linked List

Same methods as those for the Singly Linked List, except now every node in the linked list now has a pointer to the next node, and the previous one. Additionally, the last node is tracked as the tail, just as the first is tracked as the head.

Binary Search Tree

  1. addNode(element) - adds a node to the binary search tree
  2. removeNode(element) - removes a specific node from the binary search tree based on the value of the element it holds
  3. isEmpty() - console logs true or false depending on whether binary tree is empty or not
  4. findDepth(element) - console logs the depth of the specified element, if it exists

Hash Table

  1. insert(key, value) - takes a key-value pair, calculates the index via a hash function and inserts it in the table
  2. removeAt(index) - remove key-value pair from index as specified by the user
  3. removeKey(key) - remove key-value pair based on the name of the key specified by the user
  4. revealTable() - reveals the entire table to the user
  5. findIndex(key) - find the index of a particular key-value based on the key
  6. revealInfo(element) - reveals the key-value pair based on information entered by the user; the user may specify either the key or the index