@busieinc/ts-datastructures
v1.1.1
Published
Install various datastructures like LinkedLists, Queues and Stacks
Downloads
39
Readme
TS Datastructures
Common Datastructures built here for re-use across projects via NPM Install
Installation
npm install @busieinc/ts-datastructures
Usage
Linked List
import { LinkedList } from '@busieinc/ts-datastructures'
const ll = new LinkedList<string>();
node = ll.insertInBeginning('this is the head node'); // Node('this is the head node') -> null
anotherNode = ll.insertAtEnd('this is the tail node'); // Node('this is the head node') <--> Node('this is the tail node') -> null
for (const data in ll.traverse()) { // NOTE: LinkedList.prototype.traverse returns a generator
console.log(data);
}
const headNodeFromSearch = ll.search((data) => data.includes('head')); // headNodeFromSearch === node
ll.removeFromBeginning(); // Node('this is the tail node') -> null
ll.removeFromEnd();