data-structs-js
Implementation of common data structures into Javascript.
Structures included in the package:
- Stack
- Queue
- Singly linked list
- Doubly linked list
- Binary search tree
- AVL tree
- Hash table
- Hash map
- Min heap
- Max heap
- Graph
Instalation
npm install @hyperinactive/data-structs-js
Usage
Simply import a data structure from the module
e.g. const { Stack } = require('@hyperinactive/data-structs-js');
List of functions per structure
Stack
- push
- pop
- getIndex
- peek
- reverse
- isEmpty
- length
- clone
Queue
- enqueue
- dequeue
- peek
- poll
- isEmpty
- size
- clone
Singly and Doubly linked list
- getHead
- getTail (Doubly)
- getSize
- add
- removeByIndex
- removeByValue
- indexOf
- forEach
- clear
- reverse
- isEmpty
- clone
Binary search and AVL tree
- insert
- remove
- getDepth
- getHeight
- find
- getMinNode
- getMaxNode
- clone
Hash table and map
- put
- get
- remove
- update
- union
- getCurrentLoad
- getSize
- forEach
- clone
Min and max heap
- insert
- remove
- heapify
- peek
- getSize
- getParent
- getLeftChild
- getRightChild
- isLeaf
- swap
- clear
Graph
- addVertex
- addEdge
- removeVertex
- removeEdge
- removeAllEdges
- bfs
- dfs