Package Exports
- open-data
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (open-data) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
open-data
Installation
npm i open-data
Usage
let od = require('open-data');
Sorting
od.sorts.merge(/*data*/);
od.sorts.bucket();
od.sorts.radix();
od.sorts.comb();
od.sorts.quick();
//All accept an array or object with an iterator, as well as a comparator which takes two arguments
//All return a sorted array
od.sorts.isSorted();
Search
od.selections.jump(/* sorted data */, elem);
od.selections.fibonnaci(/* sorted data */, elem);
od.selections.linear(/*data*/, elem);
Data Structures
//LinkedLists
let ll = new od.structures.LinkedList();
ll.append('value');
ll.prepend('value');
ll.shift(); //returns head
ll.pop(); //returns tail
ll.remove('value', /*optional comparator*/);
ll.contains('value', /*optional comparator*/);
//same interface for DoublyLinkedList();
//Caches
// LRUcache, MRUcache, RRcache FIFOcache, LIFOcache
let lru = new od.structures.LRUcache();
lru.store('value');
lru.retrieve('value', comparator);
//OR
let findFunc = (a) => a === 'desired result';
lru.retrieve(findFunc);
//Queue and S2Queue (Queue made from 2 stacks)
let q = new od.structures.Queue();
q.enqueue('elem');
q.dequeue(); //elem
//Stack and Q2Stack (Stack made from 2 queues)
let s = new od.structures.Stack();
q.push(val);
q.pop(val);
//Bit Arrays
//Bit32Array and BitArray
let bits = new od.structures.Bit32Array();
let secondBits = new od.structures.Bit32Array();
bits.on(10);//position
secondBits.on(3);
secondBits.leftShit(2);
secondBits.isToggled(5);
//true
bits.and(secondBits);
//Returns new Bit32Array
//Trees
//Tree, BinaryTree, DoublyLinkedTree, DoublyLinkedBinaryTree
//RedBlackTree
let t = new Tree();
let root = t.insert(10);
let child1 = t.insert(15);
let otherTree = new Tree(15);
root.prune();
root.graft(otherTree);
tree.breadthFirstSearch(console.log);
tree.depthFirstSearch(console.log);
//Specifically Binary Trees:
let t = new BinaryTree(5);
t.insert(6,7,3,2);
t.contains(7);
//true
t.insert(10,10,10,10,10);
t.balance();
//Balances tree.
//Splay Trees & Graphs to come soon.
License
MIT