open-data
Installation
npm i open-data
Usage
let od = ;
Sorting
odsorts;odsorts;odsorts;odsorts;odsorts;//All accept an array or object with an iterator, as well as a comparator which takes two arguments//All return a sorted arrayodsorts;
Search
odselections;odselections;odselections;
Data Structures
//LinkedListslet ll = ;ll;ll;ll; //returns headll; //returns tailll;ll;//same interface for DoublyLinkedList();//Caches// LRUcache, MRUcache, RRcache FIFOcache, LIFOcachelet lru = ;lru;lru;//ORlet a === 'desired result';lru;//Queue and S2Queue (Queue made from 2 stacks)let q = ;q;q; //elem//Stack and Q2Stack (Stack made from 2 queues)let s = ;q;q;//Bit Arrays//Bit32Array and BitArraylet bits = ;let secondBits = ;bits;//positionsecondBits;secondBits;secondBits;//truebits;//Returns new Bit32Array//Trees//Tree, BinaryTree, DoublyLinkedTree, DoublyLinkedBinaryTree//RedBlackTreelet t = ;let root = t;let child1 = t;let otherTree = 15;root;root;tree;tree;//Specifically Binary Trees:let t = 5;t;t;//truet;t;//Balances tree.//Splay Trees & Graphs to come soon.
Matrices
const Matrix = Matrix; let a = ;let b = ;let x = 1;let y = 2;a;b;let test = ;for let i = 0; i < 100; i++ test;for let i = 0; i < 100; i++ //i represents x for a row and y for a column. a; b;//Multiplies two arrays and returns a new instance of a matrix.console;//Supports scalar multiplicationconsole;//Power functionconsole;//Uses node cluster to parallelize multiplication. Only effective when there are multiple cpus available.console; console;console;a;//retrieves element at 13, 13.a;//retrieves third row.a;//retrieves 5th column.a;a;a;//Map returns a clone with the modified value.a; //If you need to clone ita;
Bugs
Please report bugs or suggestions or fixes to julianknodt@gmail.com Thanks for using open-data <3, best of luck to you in your coding.
License
MIT