1 line
10 KiB
Plaintext
1 line
10 KiB
Plaintext
|
{"version":3,"sources":["binary-heap/max-heap.js","binary-heap/min-heap.js","binary-heap/min-max-heap.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,sB;AACA,6D;AACA,a;AACA,kE;AACA,iB;AACA,iD;AACA,0C;AACA,8B;AACA,6E;AACA,gE;AACA,0C;AACA,iC;AACA,qF;AACA,kB;;AAEA,wE;AACA,gF;AACA,gE;AACA,gC;;AAEA,wD;;AAEA,8E;AACA,mB;AACA,oC;;AAEA,4E;AACA,gF;AACA,+E;AACA,0C;AACA,kB;;AAEA,yE;AACA,6E;AACA,iC;AACA,kC;AACA,yC;AACA,E;;AAEA,6B;AACA,mE;AACA,kC;AACA,oB;;AAEA,2C;AACA,0C;AACA,O;;AAEA,kC;AACA,iC;AACA,O;;AAEA,sB;AACA,a;;AAEA,kE;AACA,yD;AACA,wB;AACA,I;;AAEA,6B;AACA,oB;;AAEA,6C;AACA,mC;AACA,qC;AACA,wB;;AAEA,+B;AACA,gD;AACA,O;AACA,gC;AACA,iD;AACA,O;;AAEA,0B;AACA,c;;AAEA,+B;AACA,oB;AACA,K;AACA,I;;AAEA,2B;AACA,oB;;AAEA,qB;AACA,kC;AACA,gD;AACA,+B;AACA,qB;AACA,c;AACA,c;AACA,O;AACA,K;AACA,I;;AAEA,oC;AACA,oB;AACA,iC;AACA,iC;AACA,+D;AACA,I;;AAEA,iE;AACA,wB;AACA,oB;AACA,iC;AACA,I;;AAEA,gC;AACA,oB;AACA,gC;AACA,gC;;AAEA,qC;AACA,qC;;AAEA,4B;AACA,4B;AACA,I;;AAEA,sB;AACA,oB;AACA,uB;AACA,kB;AACA,4C;AACA,I;AACA,6B;AACA,oB;;AAEA,uB;AACA,iC;AACA,e;;AAEA,sC;AACA,oC;;AAEA,qC;AACA,oE;AACA,wB;AACA,oE;AACA,0B;AACA,Y;AACA,+C;AACA,gD;AACA,0C;AACA,K;AACA,I;AACA,yB;AACA,oB;;AAEA,uB;AACA,uC;AACA,sC;;AAEA,yB;AACA,8B;AACA,yB;AACA,iC;;AAEA,2C;AACA,0B;AACA,4B;AACA,c;AACA,yB;AACA,iC;AACA,O;AACA,K;AACA,I;AACA,sB;AACA,oB;AACA,iC;AACA,I;AACA,sB;AACA,oB;AACA,wB;AACA,I;AACA,sB;AACA,oB;AACA,oB;AACA,0B;AACA,I;AACA,+C;AACA,gC;AACA,oB;AACA,uC;AACA,yC;AACA,O;AACA,I;AACA,qB;AACA,oB;AACA,6B;AACA,I;AACA,kC;AACA,oB;AACA,qB;AACA,0B;AACA,sB;AACA,e;AACA,I;AACA,sB;AACA,oB;AACA,0D;AACA,iB;AACA,I;;AAEA,6B;AACA,oB;AACA,iD;AACA,I;;AAEA,2B;AACA,oB;AACA,+C;AACA,2D;AACA,iE;AACA,6D;AACA,uD;AACA,G;AACA,G;;AAEA,+C;AACA,gD;AACA,+C;;;;;;;;;;;;;;;;;;;;AChOA,0C;AACA,kB;AACA,sC;AACA,6B;AACA,c;AACA,E;;AAEA,mC;;AAEA,6B;AACA,6B;AACA,2D;AACA,I;AACA,6B;AACA,oB;AACA,qD;AACA,G;AACA,G;;;;;;;;;;;;;;;;;;;;ACjBA,qE;AACA,+C;AACA,E;AACA,gF;AACA,S;AACA,E;AACA,yE;AACA,0E;AACA,+D;AACA,gF;AACA,qB;AACA,+D;AACA,6C;AACA,kB;;AAEA,0C;AACA,mD;AACA,E;;AAEA,sC;;AAEA,gC;AACA,6B;AACA,oB;AACA,iD;AACA,iC;AACA,I;AACA,yB;AACA,oB;AACA,oD;AACA,6B;AACA,I;AACA,sB;AACA,oB;AACA,mD;AACA,0B;AACA,I;AACA,kC;AACA,oB;AACA,wD;AACA,6C;AACA,I;AACA,sB;AACA,oB;AACA,6D;AACA,iB;AACA,I;AACA,6B;AACA,oB;AACA,wC;AACA,G;AACA,G","file":"/packages/binary-heap.js","sourcesContent":["// Constructor of Heap\n// - comparator - Function - given two items returns a number\n// - options:\n// - initData - Array - Optional - the initial data in a format:\n// Object:\n// - id - String - unique id of the item\n// - value - Any - the data value\n// each value is retained\n// - IdMap - Constructor - Optional - custom IdMap class to store id->index\n// mappings internally. Standard IdMap is used by default.\nMaxHeap = function (comparator, options) {\n if (! _.isFunction(comparator))\n throw new Error('Passed comparator is invalid, should be a comparison function');\n var self = this;\n\n // a C-style comparator that is given two values and returns a number,\n // negative if the first value is less than the second, positive if the second\n // value is greater than the first and zero if they are equal.\n self._comparator = comparator;\n\n options = _.defaults(options || {}, { IdMap: IdMap });\n\n // _heapIdx maps an id to an index in the Heap array the corresponding value\n // is located on.\n self._heapIdx = new options.IdMap;\n\n // The Heap data-structure implemented as a 0-based contiguous array where\n // every item on index idx is a node in a complete binary tree. Every node can\n // have children on indexes idx*2+1 and idx*2+2, except for the leaves. Every\n // node has a parent on index (idx-1)/2;\n self._heap = [];\n\n // If the initial array is passed, we can build the heap in linear time\n // complexity (O(N)) compared to linearithmic time complexity (O(nlogn)) if\n // we push elements one by one.\n if (_.isArray(options.initData))\n self._initFromData(options.initData);\n};\n\n_.extend(MaxHeap.prototype, {\n // Builds a new heap in-place in linear time based on passed data\n _initFromData: fu
|