typescript-collections
Version:
A complete, fully tested data structure library written in TypeScript.
1 lines • 30.4 kB
JavaScript
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).listComponent=t()}}(function(){return require=function t(e,n,i){function r(s,u){if(!n[s]){if(!e[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(o)return o(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var l=n[s]={exports:{}};e[s][0].call(l.exports,function(t){var n=e[s][1][t];return r(n||t)},l,l.exports,t,e,n,i)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)r(i[s]);return r}({1:[function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(n,"__esModule",{value:!0});var o=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(t("./BSTreeKV").default);n.default=o},{"./BSTreeKV":2}],2:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./util"),r=t("./Queue"),o=function(){function t(t){this.root=null,this.compare=t||i.defaultCompare,this.nElements=0}return t.prototype.add=function(t){return!i.isUndefined(t)&&(null!==this.insertNode(this.createNode(t))&&(this.nElements++,!0))},t.prototype.clear=function(){this.root=null,this.nElements=0},t.prototype.isEmpty=function(){return 0===this.nElements},t.prototype.size=function(){return this.nElements},t.prototype.contains=function(t){return!i.isUndefined(t)&&null!==this.searchNode(this.root,t)},t.prototype.search=function(t){var e=this.searchNode(this.root,t);if(null!==e)return e.element},t.prototype.remove=function(t){var e=this.searchNode(this.root,t);return null!==e&&(this.removeNode(e),this.nElements--,!0)},t.prototype.inorderTraversal=function(t){this.inorderTraversalAux(this.root,t,{stop:!1})},t.prototype.preorderTraversal=function(t){this.preorderTraversalAux(this.root,t,{stop:!1})},t.prototype.postorderTraversal=function(t){this.postorderTraversalAux(this.root,t,{stop:!1})},t.prototype.levelTraversal=function(t){this.levelTraversalAux(this.root,t)},t.prototype.minimum=function(){if(!this.isEmpty()&&null!==this.root)return this.minimumAux(this.root).element},t.prototype.maximum=function(){if(!this.isEmpty()&&null!==this.root)return this.maximumAux(this.root).element},t.prototype.forEach=function(t){this.inorderTraversal(t)},t.prototype.toArray=function(){var t=[];return this.inorderTraversal(function(e){return t.push(e),!0}),t},t.prototype.height=function(){return this.heightAux(this.root)},t.prototype.searchNode=function(t,e){for(var n=1;null!==t&&0!==n;)(n=this.compare(e,t.element))<0?t=t.leftCh:n>0&&(t=t.rightCh);return t},t.prototype.transplant=function(t,e){null===t.parent?this.root=e:t===t.parent.leftCh?t.parent.leftCh=e:t.parent.rightCh=e,null!==e&&(e.parent=t.parent)},t.prototype.removeNode=function(t){if(null===t.leftCh)this.transplant(t,t.rightCh);else if(null===t.rightCh)this.transplant(t,t.leftCh);else{var e=this.minimumAux(t.rightCh);e.parent!==t&&(this.transplant(e,e.rightCh),e.rightCh=t.rightCh,e.rightCh.parent=e),this.transplant(t,e),e.leftCh=t.leftCh,e.leftCh.parent=e}},t.prototype.inorderTraversalAux=function(t,e,n){null===t||n.stop||(this.inorderTraversalAux(t.leftCh,e,n),n.stop||(n.stop=!1===e(t.element),n.stop||this.inorderTraversalAux(t.rightCh,e,n)))},t.prototype.levelTraversalAux=function(t,e){var n=new r.default;for(null!==t&&n.enqueue(t),t=n.dequeue()||null;null!=t;){if(!1===e(t.element))return;null!==t.leftCh&&n.enqueue(t.leftCh),null!==t.rightCh&&n.enqueue(t.rightCh),t=n.dequeue()||null}},t.prototype.preorderTraversalAux=function(t,e,n){null===t||n.stop||(n.stop=!1===e(t.element),n.stop||(this.preorderTraversalAux(t.leftCh,e,n),n.stop||this.preorderTraversalAux(t.rightCh,e,n)))},t.prototype.postorderTraversalAux=function(t,e,n){null===t||n.stop||(this.postorderTraversalAux(t.leftCh,e,n),n.stop||(this.postorderTraversalAux(t.rightCh,e,n),n.stop||(n.stop=!1===e(t.element))))},t.prototype.minimumAux=function(t){for(;null!=t&&null!==t.leftCh;)t=t.leftCh;return t},t.prototype.maximumAux=function(t){for(;null!=t&&null!==t.rightCh;)t=t.rightCh;return t},t.prototype.heightAux=function(t){return null===t?-1:Math.max(this.heightAux(t.leftCh),this.heightAux(t.rightCh))+1},t.prototype.insertNode=function(t){for(var e=null,n=this.root;null!==n;){var i=this.compare(t.element,n.element);if(0===i)return null;i<0?(e=n,n=n.leftCh):(e=n,n=n.rightCh)}return t.parent=e,null===e?this.root=t:this.compare(t.element,e.element)<0?e.leftCh=t:e.rightCh=t,t},t.prototype.createNode=function(t){return{element:t,leftCh:null,rightCh:null,parent:null}},t}();n.default=o},{"./Queue":12,"./util":16}],3:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./util"),r=t("./Dictionary"),o=t("./Set"),s=function(){function t(t){this.toStrF=t||i.defaultToString,this.dictionary=new r.default(this.toStrF),this.nElements=0}return t.prototype.add=function(t,e){if(void 0===e&&(e=1),i.isUndefined(t)||e<=0)return!1;if(this.contains(t))this.dictionary.getValue(t).copies+=e;else{var n={value:t,copies:e};this.dictionary.setValue(t,n)}return this.nElements+=e,!0},t.prototype.count=function(t){return this.contains(t)?this.dictionary.getValue(t).copies:0},t.prototype.contains=function(t){return this.dictionary.containsKey(t)},t.prototype.remove=function(t,e){if(void 0===e&&(e=1),i.isUndefined(t)||e<=0)return!1;if(this.contains(t)){var n=this.dictionary.getValue(t);return e>n.copies?this.nElements-=n.copies:this.nElements-=e,n.copies-=e,n.copies<=0&&this.dictionary.remove(t),!0}return!1},t.prototype.toArray=function(){for(var t=[],e=0,n=this.dictionary.values();e<n.length;e++)for(var i=n[e],r=i.value,o=i.copies,s=0;s<o;s++)t.push(r);return t},t.prototype.toSet=function(){for(var t=new o.default(this.toStrF),e=0,n=this.dictionary.values();e<n.length;e++){var i=n[e].value;t.add(i)}return t},t.prototype.forEach=function(t){this.dictionary.forEach(function(e,n){for(var i=n.value,r=n.copies,o=0;o<r;o++)if(!1===t(i))return!1;return!0})},t.prototype.size=function(){return this.nElements},t.prototype.isEmpty=function(){return 0===this.nElements},t.prototype.clear=function(){this.nElements=0,this.dictionary.clear()},t}();n.default=s},{"./Dictionary":4,"./Set":13,"./util":16}],4:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./util"),r=function(){function t(t){this.table={},this.nElements=0,this.toStr=t||i.defaultToString}return t.prototype.getValue=function(t){var e=this.table["$"+this.toStr(t)];if(!i.isUndefined(e))return e.value},t.prototype.setValue=function(t,e){if(!i.isUndefined(t)&&!i.isUndefined(e)){var n,r="$"+this.toStr(t),o=this.table[r];return i.isUndefined(o)?(this.nElements++,n=void 0):n=o.value,this.table[r]={key:t,value:e},n}},t.prototype.remove=function(t){var e="$"+this.toStr(t),n=this.table[e];if(!i.isUndefined(n))return delete this.table[e],this.nElements--,n.value},t.prototype.keys=function(){var t=[];for(var e in this.table)if(i.has(this.table,e)){var n=this.table[e];t.push(n.key)}return t},t.prototype.values=function(){var t=[];for(var e in this.table)if(i.has(this.table,e)){var n=this.table[e];t.push(n.value)}return t},t.prototype.forEach=function(t){for(var e in this.table)if(i.has(this.table,e)){var n=this.table[e];if(!1===t(n.key,n.value))return}},t.prototype.containsKey=function(t){return!i.isUndefined(this.getValue(t))},t.prototype.clear=function(){this.table={},this.nElements=0},t.prototype.size=function(){return this.nElements},t.prototype.isEmpty=function(){return this.nElements<=0},t.prototype.toString=function(){var t="{";return this.forEach(function(e,n){t+="\n\t"+e+" : "+n}),t+"\n}"},t}();n.default=r},{"./util":16}],5:[function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(n,"__esModule",{value:!0});var o=t("./Dictionary"),s=t("./util"),u=function(t){function e(e,n){var i=t.call(this,n)||this;return i.defaultFactoryFunction=e,i}return r(e,t),e.prototype.setDefault=function(e,n){var i=t.prototype.getValue.call(this,e);return s.isUndefined(i)?(this.setValue(e,n),n):i},e.prototype.getValue=function(t){return this.setDefault(t,this.defaultFactoryFunction())},e}(o.default);n.default=u},{"./Dictionary":4,"./util":16}],6:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./util"),r=t("./arrays"),o=function(){function t(t){this.data=[],this.compare=t||i.defaultCompare}return t.prototype.leftChildIndex=function(t){return 2*t+1},t.prototype.rightChildIndex=function(t){return 2*t+2},t.prototype.parentIndex=function(t){return Math.floor((t-1)/2)},t.prototype.minIndex=function(t,e){return e>=this.data.length?t>=this.data.length?-1:t:this.compare(this.data[t],this.data[e])<=0?t:e},t.prototype.siftUp=function(t){for(var e=this.parentIndex(t);t>0&&this.compare(this.data[e],this.data[t])>0;)r.swap(this.data,e,t),t=e,e=this.parentIndex(t)},t.prototype.siftDown=function(t){for(var e=this.minIndex(this.leftChildIndex(t),this.rightChildIndex(t));e>=0&&this.compare(this.data[t],this.data[e])>0;)r.swap(this.data,e,t),t=e,e=this.minIndex(this.leftChildIndex(t),this.rightChildIndex(t))},t.prototype.peek=function(){return this.data.length>0?this.data[0]:void 0},t.prototype.add=function(t){return!i.isUndefined(t)&&(this.data.push(t),this.siftUp(this.data.length-1),!0)},t.prototype.removeRoot=function(){if(this.data.length>0){var t=this.data[0];return this.data[0]=this.data[this.data.length-1],this.data.splice(this.data.length-1,1),this.data.length>0&&this.siftDown(0),t}},t.prototype.contains=function(t){var e=i.compareToEquals(this.compare);return r.contains(this.data,t,e)},t.prototype.size=function(){return this.data.length},t.prototype.isEmpty=function(){return this.data.length<=0},t.prototype.clear=function(){this.data.length=0},t.prototype.forEach=function(t){r.forEach(this.data,t)},t}();n.default=o},{"./arrays":15,"./util":16}],7:[function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(n,"__esModule",{value:!0});var o=t("./Dictionary"),s=t("./util"),u=function(){function t(t,e){this.key=t,this.value=e}return t.prototype.unlink=function(){this.prev.next=this.next,this.next.prev=this.prev},t}(),a=function(){function t(){this.key=null,this.value=null}return t.prototype.unlink=function(){this.prev.next=this.next,this.next.prev=this.prev},t}();var h=function(t){function e(e){var n=t.call(this,e)||this;return n.head=new a,n.tail=new a,n.head.next=n.tail,n.tail.prev=n.head,n}return r(e,t),e.prototype.appendToTail=function(t){var e=this.tail.prev;e.next=t,t.prev=e,t.next=this.tail,this.tail.prev=t},e.prototype.getLinkedDictionaryPair=function(t){if(!s.isUndefined(t)){var e="$"+this.toStr(t);return this.table[e]}},e.prototype.getValue=function(t){var e=this.getLinkedDictionaryPair(t);if(!s.isUndefined(e))return e.value},e.prototype.remove=function(e){var n=this.getLinkedDictionaryPair(e);if(!s.isUndefined(n))return t.prototype.remove.call(this,e),n.unlink(),n.value},e.prototype.clear=function(){t.prototype.clear.call(this),this.head.next=this.tail,this.tail.prev=this.head},e.prototype.replace=function(t,e){var n="$"+this.toStr(e.key);e.next=t.next,e.prev=t.prev,this.remove(t.key),e.prev.next=e,e.next.prev=e,this.table[n]=e,++this.nElements},e.prototype.setValue=function(t,e){if(!s.isUndefined(t)&&!s.isUndefined(e)){var n=this.getLinkedDictionaryPair(t),i=new u(t,e),r="$"+this.toStr(t);return s.isUndefined(n)?(this.appendToTail(i),this.table[r]=i,void++this.nElements):(this.replace(n,i),n.value)}},e.prototype.keys=function(){var t=[];return this.forEach(function(e,n){t.push(e)}),t},e.prototype.values=function(){var t=[];return this.forEach(function(e,n){t.push(n)}),t},e.prototype.forEach=function(t){for(var e=this.head.next;e.next;){if(!1===t(e.key,e.value))return;e=e.next}},e}(o.default);n.default=h},{"./Dictionary":4,"./util":16}],8:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./util"),r=t("./arrays"),o=function(){function t(){this.firstNode=null,this.lastNode=null,this.nElements=0}return t.prototype.add=function(t,e){if(i.isUndefined(e)&&(e=this.nElements),e<0||e>this.nElements||i.isUndefined(t))return!1;var n=this.createNode(t);if(0===this.nElements||null===this.lastNode)this.firstNode=n,this.lastNode=n;else if(e===this.nElements)this.lastNode.next=n,this.lastNode=n;else if(0===e)n.next=this.firstNode,this.firstNode=n;else{var r=this.nodeAtIndex(e-1);if(null===r)return!1;n.next=r.next,r.next=n}return this.nElements++,!0},t.prototype.first=function(){if(null!==this.firstNode)return this.firstNode.element},t.prototype.last=function(){if(null!==this.lastNode)return this.lastNode.element},t.prototype.elementAtIndex=function(t){var e=this.nodeAtIndex(t);if(null!==e)return e.element},t.prototype.indexOf=function(t,e){var n=e||i.defaultEquals;if(i.isUndefined(t))return-1;for(var r=this.firstNode,o=0;null!==r;){if(n(r.element,t))return o;o++,r=r.next}return-1},t.prototype.contains=function(t,e){return this.indexOf(t,e)>=0},t.prototype.remove=function(t,e){var n=e||i.defaultEquals;if(this.nElements<1||i.isUndefined(t))return!1;for(var r=null,o=this.firstNode;null!==o;){if(n(o.element,t))return null===r?(this.firstNode=o.next,o===this.lastNode&&(this.lastNode=null)):o===this.lastNode?(this.lastNode=r,r.next=o.next,o.next=null):(r.next=o.next,o.next=null),this.nElements--,!0;r=o,o=o.next}return!1},t.prototype.clear=function(){this.firstNode=null,this.lastNode=null,this.nElements=0},t.prototype.equals=function(e,n){var r=n||i.defaultEquals;return e instanceof t&&(this.size()===e.size()&&this.equalsAux(this.firstNode,e.firstNode,r))},t.prototype.equalsAux=function(t,e,n){for(;null!==t&&null!==e;){if(!n(t.element,e.element))return!1;t=t.next,e=e.next}return!0},t.prototype.removeElementAtIndex=function(t){if(!(t<0||t>=this.nElements||null===this.firstNode||null===this.lastNode)){var e;if(1===this.nElements)e=this.firstNode.element,this.firstNode=null,this.lastNode=null;else{var n=this.nodeAtIndex(t-1);null===n?(e=this.firstNode.element,this.firstNode=this.firstNode.next):n.next===this.lastNode&&(e=this.lastNode.element,this.lastNode=n),null!==n&&null!==n.next&&(e=n.next.element,n.next=n.next.next)}return this.nElements--,e}},t.prototype.forEach=function(t){for(var e=this.firstNode;null!==e&&!1!==t(e.element);)e=e.next},t.prototype.reverse=function(){for(var t=null,e=this.firstNode,n=null;null!==e;)n=e.next,e.next=t,t=e,e=n;n=this.firstNode,this.firstNode=this.lastNode,this.lastNode=n},t.prototype.toArray=function(){for(var t=[],e=this.firstNode;null!==e;)t.push(e.element),e=e.next;return t},t.prototype.size=function(){return this.nElements},t.prototype.isEmpty=function(){return this.nElements<=0},t.prototype.toString=function(){return r.toString(this.toArray())},t.prototype.nodeAtIndex=function(t){if(t<0||t>=this.nElements)return null;if(t===this.nElements-1)return this.lastNode;for(var e=this.firstNode,n=0;n<t&&null!==e;n++)e=e.next;return e},t.prototype.createNode=function(t){return{element:t,next:null}},t}();n.default=o},{"./arrays":15,"./util":16}],9:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./util"),r=t("./Dictionary"),o=t("./arrays"),s=function(){function t(t,e,n){void 0===n&&(n=!1),this.dict=new r.default(t),this.equalsF=e||i.defaultEquals,this.allowDuplicate=n}return t.prototype.getValue=function(t){var e=this.dict.getValue(t);return i.isUndefined(e)?[]:o.copy(e)},t.prototype.setValue=function(t,e){if(i.isUndefined(t)||i.isUndefined(e))return!1;var n=this.dict.getValue(t);return i.isUndefined(n)?(this.dict.setValue(t,[e]),!0):!(!this.allowDuplicate&&o.contains(n,e,this.equalsF))&&(n.push(e),!0)},t.prototype.remove=function(t,e){if(i.isUndefined(e)){var n=this.dict.remove(t);return!i.isUndefined(n)}var r=this.dict.getValue(t);return!(i.isUndefined(r)||!o.remove(r,e,this.equalsF))&&(0===r.length&&this.dict.remove(t),!0)},t.prototype.keys=function(){return this.dict.keys()},t.prototype.values=function(){for(var t=[],e=0,n=this.dict.values();e<n.length;e++)for(var i=0,r=n[e];i<r.length;i++){var o=r[i];t.push(o)}return t},t.prototype.containsKey=function(t){return this.dict.containsKey(t)},t.prototype.clear=function(){this.dict.clear()},t.prototype.size=function(){return this.dict.size()},t.prototype.isEmpty=function(){return this.dict.isEmpty()},t}();n.default=s},{"./Dictionary":4,"./arrays":15,"./util":16}],10:[function(t,e,n){"use strict";var i,r;Object.defineProperty(n,"__esModule",{value:!0}),(r=i||(i={}))[r.BEFORE=0]="BEFORE",r[r.AFTER=1]="AFTER",r[r.INSIDE_AT_END=2]="INSIDE_AT_END",r[r.INSIDE_AT_START=3]="INSIDE_AT_START";var o=function(){function t(t,e){void 0===t&&(t=[]),void 0===e&&(e={}),this.rootIds=t,this.nodes=e,this.initRootIds(),this.initNodes()}return t.prototype.initRootIds=function(){for(var t=0,e=this.rootIds;t<e.length;t++){var n=e[t];this.createEmptyNodeIfNotExist(n)}},t.prototype.initNodes=function(){for(var t in this.nodes)if(this.nodes.hasOwnProperty(t))for(var e=0,n=this.nodes[t];e<n.length;e++){var i=n[e];this.createEmptyNodeIfNotExist(i)}},t.prototype.createEmptyNodeIfNotExist=function(t){this.nodes[t]||(this.nodes[t]=[])},t.prototype.getRootIds=function(){return this.rootIds.slice()},t.prototype.getNodes=function(){var t={};for(var e in this.nodes)this.nodes.hasOwnProperty(e)&&(t[e]=this.nodes[e].slice());return t},t.prototype.getObject=function(){return{rootIds:this.getRootIds(),nodes:this.getNodes()}},t.prototype.toObject=function(){return this.getObject()},t.prototype.flatten=function(){for(var t=this,e=[],n=0;n<this.rootIds.length;n++){var i=this.rootIds[n];e.push({id:i,level:0,hasParent:!1,childrenCount:0}),a(i,this.nodes,e,0)}for(var r=0,o=e;r<o.length;r++){var s=o[r];s.childrenCount=u(s.id)}return e;function u(e){return t.nodes[e]?t.nodes[e].length:0}function a(t,e,n,i){if(void 0===i&&(i=0),t&&e&&n&&e[t]){i++;for(var r=e[t],o=0;o<r.length;o++){var s=r[o];n.push({id:s,level:i,hasParent:!0}),a(s,e,n,i)}i--}}},t.prototype.moveIdBeforeId=function(t,e){return this.moveId(t,e,i.BEFORE)},t.prototype.moveIdAfterId=function(t,e){return this.moveId(t,e,i.AFTER)},t.prototype.moveIdIntoId=function(t,e,n){return void 0===n&&(n=!0),n?this.moveId(t,e,i.INSIDE_AT_START):this.moveId(t,e,i.INSIDE_AT_END)},t.prototype.swapRootIdWithRootId=function(t,e){var n=this.findRootId(t),i=this.findRootId(e);this.swapRootPositionWithRootPosition(n,i)},t.prototype.swapRootPositionWithRootPosition=function(t,e){var n=this.rootIds[e];this.rootIds[e]=this.rootIds[t],this.rootIds[t]=n},t.prototype.deleteId=function(t){this.rootDeleteId(t),this.nodeAndSubNodesDelete(t),this.nodeRefrencesDelete(t)},t.prototype.insertIdBeforeId=function(t,e){var n=this.findRootId(t);for(var i in n>-1&&this.insertIdIntoRoot(e,n),this.nodes)if(this.nodes.hasOwnProperty(i)){var r=this.findNodeId(i,t);r>-1&&this.insertIdIntoNode(i,e,r)}},t.prototype.insertIdAfterId=function(t,e){var n=this.findRootId(t);for(var i in n>-1&&this.insertIdIntoRoot(e,n+1),this.nodes)if(this.nodes.hasOwnProperty(i)){var r=this.findNodeId(i,t);r>-1&&this.insertIdIntoNode(i,e,r+1)}},t.prototype.insertIdIntoId=function(t,e){this.nodeInsertAtEnd(t,e),this.nodes[e]=[]},t.prototype.insertIdIntoRoot=function(t,e){if(void 0===e)this.rootInsertAtEnd(t);else if(e<0){var n=this.rootIds.length;this.rootIds.splice(e+n+1,0,t)}else this.rootIds.splice(e,0,t);this.nodes[t]=this.nodes[t]||[]},t.prototype.insertIdIntoNode=function(t,e,n){if(this.nodes[t]=this.nodes[t]||[],this.nodes[e]=this.nodes[e]||[],void 0===n)this.nodeInsertAtEnd(t,e);else if(n<0){var i=this.nodes[t].length;this.nodes[t].splice(n+i+1,0,e)}else this.nodes[t].splice(n,0,e)},t.prototype.moveId=function(t,e,n){var r=t,o=this.findRootId(r);for(var s in this.nodes[e]&&e,this.nodes)if(this.nodes.hasOwnProperty(s)){this.findNodeId(s,e);break}var u=e,a=this.findRootId(u);for(var s in this.nodes[e]&&e,this.nodes)if(this.nodes.hasOwnProperty(s)){this.findNodeId(s,e);break}if(o>-1)if(a>-1)switch(this.rootDelete(o),a>o&&a--,n){case i.BEFORE:this.insertIdIntoRoot(r,a);break;case i.AFTER:this.insertIdIntoRoot(r,a+1);break;case i.INSIDE_AT_START:this.nodeInsertAtStart(u,r);break;case i.INSIDE_AT_END:this.nodeInsertAtEnd(u,r)}else for(var s in this.rootDelete(o),this.nodes){if(this.nodes.hasOwnProperty(s))if((h=this.findNodeId(s,u))>-1){switch(n){case i.BEFORE:this.insertIdIntoNode(s,r,h);break;case i.AFTER:this.insertIdIntoNode(s,r,h+1);break;case i.INSIDE_AT_START:this.nodeInsertAtStart(u,r);break;case i.INSIDE_AT_END:this.nodeInsertAtEnd(u,r)}break}}else if(a>-1){for(var s in this.nodes){if(this.nodes.hasOwnProperty(s))if((h=this.findNodeId(s,r))>-1){this.nodeDeleteAtIndex(s,h);break}}switch(n){case i.BEFORE:this.insertIdIntoRoot(r,a);break;case i.AFTER:this.insertIdIntoRoot(r,a+1);break;case i.INSIDE_AT_START:this.nodeInsertAtStart(u,r);break;case i.INSIDE_AT_END:this.nodeInsertAtEnd(u,r)}}else{for(var s in this.nodes){if(this.nodes.hasOwnProperty(s))if((h=this.findNodeId(s,r))>-1){this.nodeDeleteAtIndex(s,h);break}}for(var s in this.nodes){var h;if(this.nodes.hasOwnProperty(s))if((h=this.findNodeId(s,u))>-1){switch(n){case i.BEFORE:this.insertIdIntoNode(s,r,h);break;case i.AFTER:this.insertIdIntoNode(s,r,h+1);break;case i.INSIDE_AT_START:this.nodeInsertAtStart(u,r);break;case i.INSIDE_AT_END:this.nodeInsertAtEnd(u,r)}break}}}},t.prototype.swapArrayElements=function(t,e,n){var i=t[e];return t[e]=t[n],t[n]=i,t},t.prototype.rootDeleteId=function(t){var e=this.findRootId(t);e>-1&&this.rootDelete(e)},t.prototype.nodeAndSubNodesDelete=function(t){for(var e=[],n=0;n<this.nodes[t].length;n++){var i=this.nodes[t][n];this.nodeAndSubNodesDelete(i),e.push(t)}this.nodeDelete(t);for(n=0;n<e.length;n++)this.nodeDelete(e[n])},t.prototype.nodeRefrencesDelete=function(t){for(var e in this.nodes)if(this.nodes.hasOwnProperty(e))for(var n=0;n<this.nodes[e].length;n++){this.nodes[e][n]===t&&this.nodeDeleteAtIndex(e,n)}},t.prototype.nodeDelete=function(t){delete this.nodes[t]},t.prototype.findRootId=function(t){return this.rootIds.indexOf(t)},t.prototype.findNodeId=function(t,e){return this.nodes[t].indexOf(e)},t.prototype.findNode=function(t){return this.nodes[t]},t.prototype.nodeInsertAtStart=function(t,e){this.nodes[t].unshift(e)},t.prototype.nodeInsertAtEnd=function(t,e){this.nodes[t].push(e)},t.prototype.rootDelete=function(t){this.rootIds.splice(t,1)},t.prototype.nodeDeleteAtIndex=function(t,e){this.nodes[t].splice(e,1)},t.prototype.rootInsertAtStart=function(t){this.rootIds.unshift(t)},t.prototype.rootInsertAtEnd=function(t){this.rootIds.push(t)},t}();n.default=o},{}],11:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./util"),r=t("./Heap"),o=function(){function t(t){this.heap=new r.default(i.reverseCompareFunction(t))}return t.prototype.enqueue=function(t){return this.heap.add(t)},t.prototype.add=function(t){return this.heap.add(t)},t.prototype.dequeue=function(){if(0!==this.heap.size()){var t=this.heap.peek();return this.heap.removeRoot(),t}},t.prototype.peek=function(){return this.heap.peek()},t.prototype.contains=function(t){return this.heap.contains(t)},t.prototype.isEmpty=function(){return this.heap.isEmpty()},t.prototype.size=function(){return this.heap.size()},t.prototype.clear=function(){this.heap.clear()},t.prototype.forEach=function(t){this.heap.forEach(t)},t}();n.default=o},{"./Heap":6,"./util":16}],12:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./LinkedList"),r=function(){function t(){this.list=new i.default}return t.prototype.enqueue=function(t){return this.list.add(t)},t.prototype.add=function(t){return this.list.add(t)},t.prototype.dequeue=function(){if(0!==this.list.size()){var t=this.list.first();return this.list.removeElementAtIndex(0),t}},t.prototype.peek=function(){if(0!==this.list.size())return this.list.first()},t.prototype.size=function(){return this.list.size()},t.prototype.contains=function(t,e){return this.list.contains(t,e)},t.prototype.isEmpty=function(){return this.list.size()<=0},t.prototype.clear=function(){this.list.clear()},t.prototype.forEach=function(t){this.list.forEach(t)},t}();n.default=r},{"./LinkedList":8}],13:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./util"),r=t("./arrays"),o=t("./Dictionary"),s=function(){function t(t){this.dictionary=new o.default(t)}return t.prototype.contains=function(t){return this.dictionary.containsKey(t)},t.prototype.add=function(t){return!this.contains(t)&&!i.isUndefined(t)&&(this.dictionary.setValue(t,t),!0)},t.prototype.intersection=function(t){var e=this;this.forEach(function(n){return t.contains(n)||e.remove(n),!0})},t.prototype.union=function(t){var e=this;t.forEach(function(t){return e.add(t),!0})},t.prototype.difference=function(t){var e=this;t.forEach(function(t){return e.remove(t),!0})},t.prototype.isSubsetOf=function(t){if(this.size()>t.size())return!1;var e=!0;return this.forEach(function(n){return!!t.contains(n)||(e=!1,!1)}),e},t.prototype.remove=function(t){return!!this.contains(t)&&(this.dictionary.remove(t),!0)},t.prototype.forEach=function(t){this.dictionary.forEach(function(e,n){return t(n)})},t.prototype.toArray=function(){return this.dictionary.values()},t.prototype.isEmpty=function(){return this.dictionary.isEmpty()},t.prototype.size=function(){return this.dictionary.size()},t.prototype.clear=function(){this.dictionary.clear()},t.prototype.toString=function(){return r.toString(this.toArray())},t}();n.default=s},{"./Dictionary":4,"./arrays":15,"./util":16}],14:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./LinkedList"),r=function(){function t(){this.list=new i.default}return t.prototype.push=function(t){return this.list.add(t,0)},t.prototype.add=function(t){return this.list.add(t,0)},t.prototype.pop=function(){return this.list.removeElementAtIndex(0)},t.prototype.peek=function(){return this.list.first()},t.prototype.size=function(){return this.list.size()},t.prototype.contains=function(t,e){return this.list.contains(t,e)},t.prototype.isEmpty=function(){return this.list.isEmpty()},t.prototype.clear=function(){this.list.clear()},t.prototype.forEach=function(t){this.list.forEach(t)},t}();n.default=r},{"./LinkedList":8}],15:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./util");function r(t,e,n){for(var r=n||i.defaultEquals,o=t.length,s=0;s<o;s++)if(r(t[s],e))return s;return-1}n.indexOf=r,n.lastIndexOf=function(t,e,n){for(var r=n||i.defaultEquals,o=t.length-1;o>=0;o--)if(r(t[o],e))return o;return-1},n.contains=function(t,e,n){return r(t,e,n)>=0},n.remove=function(t,e,n){var i=r(t,e,n);return!(i<0||(t.splice(i,1),0))},n.frequency=function(t,e,n){for(var r=n||i.defaultEquals,o=t.length,s=0,u=0;u<o;u++)r(t[u],e)&&s++;return s},n.equals=function(t,e,n){var r=n||i.defaultEquals;if(t.length!==e.length)return!1;for(var o=t.length,s=0;s<o;s++)if(!r(t[s],e[s]))return!1;return!0},n.copy=function(t){return t.concat()},n.swap=function(t,e,n){if(e<0||e>=t.length||n<0||n>=t.length)return!1;var i=t[e];return t[e]=t[n],t[n]=i,!0},n.toString=function(t){return"["+t.toString()+"]"},n.forEach=function(t,e){for(var n=0,i=t;n<i.length;n++)if(!1===e(i[n]))return}},{"./util":16}],16:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=Object.prototype.hasOwnProperty;function r(t){return"function"==typeof t}function o(t){return void 0===t}function s(t){return"[object String]"===Object.prototype.toString.call(t)}n.has=function(t,e){return i.call(t,e)},n.defaultCompare=function(t,e){return t<e?-1:t===e?0:1},n.defaultEquals=function(t,e){return t===e},n.defaultToString=function(t){return null===t?"COLLECTION_NULL":o(t)?"COLLECTION_UNDEFINED":s(t)?"$s"+t:"$o"+t.toString()},n.makeString=function(t,e){if(void 0===e&&(e=","),null===t)return"COLLECTION_NULL";if(o(t))return"COLLECTION_UNDEFINED";if(s(t))return t.toString();var i="{",r=!0;for(var u in t)n.has(t,u)&&(r?r=!1:i+=e,i=i+u+":"+t[u]);return i+"}"},n.isFunction=r,n.isUndefined=o,n.isString=s,n.reverseCompareFunction=function(t){return o(t)||!r(t)?function(t,e){return t<e?1:t===e?0:-1}:function(e,n){return-1*t(e,n)}},n.compareToEquals=function(t){return function(e,n){return 0===t(e,n)}}},{}],"typescript-collections":[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./arrays");n.arrays=i;var r=t("./Bag");n.Bag=r.default;var o=t("./BSTree");n.BSTree=o.default;var s=t("./BSTreeKV");n.BSTreeKV=s.default;var u=t("./Dictionary");n.Dictionary=u.default;var a=t("./Heap");n.Heap=a.default;var h=t("./LinkedDictionary");n.LinkedDictionary=h.default;var l=t("./LinkedList");n.LinkedList=l.default;var f=t("./MultiDictionary");n.MultiDictionary=f.default;var d=t("./FactoryDictionary");n.FactoryDictionary=d.default;var p=t("./FactoryDictionary");n.DefaultDictionary=p.default;var c=t("./Queue");n.Queue=c.default;var y=t("./PriorityQueue");n.PriorityQueue=y.default;var v=t("./Set");n.Set=v.default;var m=t("./Stack");n.Stack=m.default;var I=t("./MultiRootTree");n.MultiRootTree=I.default;var E=t("./util");n.util=E},{"./BSTree":1,"./BSTreeKV":2,"./Bag":3,"./Dictionary":4,"./FactoryDictionary":5,"./Heap":6,"./LinkedDictionary":7,"./LinkedList":8,"./MultiDictionary":9,"./MultiRootTree":10,"./PriorityQueue":11,"./Queue":12,"./Set":13,"./Stack":14,"./arrays":15,"./util":16}]},{},[]),require("typescript-collections")});