js-sorted-set
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "js-sorted-set", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Sorted set data structures", | ||
@@ -28,23 +28,24 @@ "main": "sorted-set.js", | ||
"devDependencies": { | ||
"browserify": "~5.10.0", | ||
"chai": "~1.9.1", | ||
"coffeeify": "~0.7.0", | ||
"browserify": "^11.0.1", | ||
"chai": "^3.2.0", | ||
"coffeeify": "^1.1.0", | ||
"gulp": "^3.9.0", | ||
"gulp-coffee": "~2.1.1", | ||
"gulp-coffee": "^2.3.1", | ||
"gulp-derequire": "^2.1.0", | ||
"gulp-mocha": "~1.0.0", | ||
"gulp-rename": "~1.2.0", | ||
"gulp-rimraf": "~0.1.0", | ||
"gulp-uglify": "~0.3.1", | ||
"gulp-util": "~3.0.0", | ||
"karma": "~0.12.21", | ||
"karma-browserifast": "~0.7.0", | ||
"gulp-mocha": "^2.1.3", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-rimraf": "^0.1.1", | ||
"gulp-uglify": "^1.2.0", | ||
"gulp-util": "^3.0.6", | ||
"karma": "^0.13.9", | ||
"karma-browserify": "^4.3.0", | ||
"karma-chai": "~0.1.0", | ||
"karma-mocha": "~0.1.7", | ||
"karma-phantomjs-launcher": "~0.1.4", | ||
"mocha": "~1.21.4", | ||
"sinon": "~1.10.3", | ||
"sinon-chai": "~2.5.0", | ||
"vinyl-source-stream": "~0.1.1" | ||
"karma-mocha": "^0.2.0", | ||
"karma-phantomjs-launcher": "^0.2.1", | ||
"mocha": "^2.2.5", | ||
"phantomjs": "^1.9.18", | ||
"sinon": "^1.15.4", | ||
"sinon-chai": "^2.8.0", | ||
"vinyl-source-stream": "^1.1.0" | ||
} | ||
} |
@@ -57,2 +57,3 @@ Sorted Set | ||
| Remove | `set.remove(value);` | | ||
| Clear | `set.clear();` | | ||
| Length | `set.length;` | | ||
@@ -162,2 +163,3 @@ | Test | `set.contains(value);` | Returns `true` or `false` | | ||
| Length | O(1) | O(1) | O(1) | | ||
| Clear | O(1) | O(n) (in garbage collector) | O(n) (in garbage collector) | | ||
| Insert | O(n) (often slow) | O(n) (often slow) | O(lg n) (fast) | | ||
@@ -164,0 +166,0 @@ | Remove | O(n) (often slow) | O(n) (often slow) | O(lg n) (fast) | |
@@ -1,5 +0,5 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.SortedSet=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SortedSet = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
var AbstractSortedSet, ArrayStrategy, BinaryTreeStrategy, RedBlackTreeStrategy, SortedSet, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -14,4 +14,4 @@ AbstractSortedSet = _dereq_('./SortedSet/AbstractSortedSet'); | ||
SortedSet = (function(_super) { | ||
__extends(SortedSet, _super); | ||
SortedSet = (function(superClass) { | ||
extend(SortedSet, superClass); | ||
@@ -40,3 +40,2 @@ function SortedSet(options) { | ||
},{"./SortedSet/AbstractSortedSet":3,"./SortedSet/ArrayStrategy":4,"./SortedSet/BinaryTreeStrategy":6,"./SortedSet/RedBlackTreeStrategy":7}],2:[function(_dereq_,module,exports){ | ||
@@ -68,2 +67,6 @@ var AbstractBinaryTree, BinaryTreeIterator, binaryTreeTraverse; | ||
AbstractBinaryTree.prototype.clear = function() { | ||
return this.root = null; | ||
}; | ||
AbstractBinaryTree.prototype.forEachImpl = function(callback, sortedSet, thisArg) { | ||
@@ -115,3 +118,2 @@ var i; | ||
},{"./BinaryTreeIterator":5}],3:[function(_dereq_,module,exports){ | ||
@@ -144,2 +146,8 @@ var AbstractSortedSet; | ||
AbstractSortedSet.prototype.clear = function() { | ||
this.priv.clear(); | ||
this.length = 0; | ||
return this; | ||
}; | ||
AbstractSortedSet.prototype.contains = function(value) { | ||
@@ -217,3 +225,2 @@ return this.priv.contains(value); | ||
},{}],4:[function(_dereq_,module,exports){ | ||
@@ -223,5 +230,5 @@ var ArrayStrategy, Iterator, binarySearchForIndex; | ||
Iterator = (function() { | ||
function Iterator(priv, index) { | ||
function Iterator(priv, index1) { | ||
this.priv = priv; | ||
this.index = index; | ||
this.index = index1; | ||
this.data = this.priv.data; | ||
@@ -320,2 +327,6 @@ } | ||
ArrayStrategy.prototype.clear = function() { | ||
return this.data.length = 0; | ||
}; | ||
ArrayStrategy.prototype.contains = function(value) { | ||
@@ -328,6 +339,6 @@ var index; | ||
ArrayStrategy.prototype.forEachImpl = function(callback, sortedSet, thisArg) { | ||
var index, value, _i, _len, _ref; | ||
_ref = this.data; | ||
for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) { | ||
value = _ref[index]; | ||
var i, index, len, ref, value; | ||
ref = this.data; | ||
for (index = i = 0, len = ref.length; i < len; index = ++i) { | ||
value = ref[index]; | ||
callback.call(thisArg, value, index, sortedSet); | ||
@@ -359,3 +370,2 @@ } | ||
},{}],5:[function(_dereq_,module,exports){ | ||
@@ -392,5 +402,5 @@ var BinaryTreeIterator, descendAllTheWay, moveCursor; | ||
BinaryTreeIterator = (function() { | ||
function BinaryTreeIterator(tree, node) { | ||
this.tree = tree; | ||
this.node = node; | ||
function BinaryTreeIterator(tree1, node1) { | ||
this.tree = tree1; | ||
this.node = node1; | ||
} | ||
@@ -508,7 +518,6 @@ | ||
},{}],6:[function(_dereq_,module,exports){ | ||
var AbstractBinaryTreeStrategy, BinaryTreeStrategy, Node, binaryTreeDelete, nodeAllTheWay, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -518,4 +527,4 @@ AbstractBinaryTreeStrategy = _dereq_('./AbstractBinaryTreeStrategy'); | ||
Node = (function() { | ||
function Node(value) { | ||
this.value = value; | ||
function Node(value1) { | ||
this.value = value1; | ||
this.left = null; | ||
@@ -562,4 +571,4 @@ this.right = null; | ||
BinaryTreeStrategy = (function(_super) { | ||
__extends(BinaryTreeStrategy, _super); | ||
BinaryTreeStrategy = (function(superClass) { | ||
extend(BinaryTreeStrategy, superClass); | ||
@@ -605,7 +614,6 @@ function BinaryTreeStrategy(options) { | ||
},{"./AbstractBinaryTreeStrategy":2}],7:[function(_dereq_,module,exports){ | ||
var AbstractBinaryTreeStrategy, Node, RedBlackTreeStrategy, colorFlip, findMinNode, fixUp, insertInNode, moveRedLeft, moveRedRight, removeFromNode, removeMinNode, rotateLeft, rotateRight, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -615,4 +623,4 @@ AbstractBinaryTreeStrategy = _dereq_('./AbstractBinaryTreeStrategy'); | ||
Node = (function() { | ||
function Node(value) { | ||
this.value = value; | ||
function Node(value1) { | ||
this.value = value1; | ||
this.left = null; | ||
@@ -768,4 +776,4 @@ this.right = null; | ||
module.exports = RedBlackTreeStrategy = (function(_super) { | ||
__extends(RedBlackTreeStrategy, _super); | ||
module.exports = RedBlackTreeStrategy = (function(superClass) { | ||
extend(RedBlackTreeStrategy, superClass); | ||
@@ -797,4 +805,3 @@ function RedBlackTreeStrategy(options) { | ||
},{"./AbstractBinaryTreeStrategy":2}]},{},[1])(1) | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r;"undefined"!=typeof window?r=window:"undefined"!=typeof global?r=global:"undefined"!=typeof self&&(r=self),r.SortedSet=t()}}(function(){return function t(r,e,n){function o(u,l){if(!e[u]){if(!r[u]){var a="function"==typeof require&&require;if(!l&&a)return a(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var f=e[u]={exports:{}};r[u][0].call(f.exports,function(t){var e=r[u][1][t];return o(e?e:t)},f,f.exports,t,r,e,n)}return e[u].exports}for(var i="function"==typeof require&&require,u=0;u<n.length;u++)o(n[u]);return o}({1:[function(t,r){var e,n,o,i,u,l={}.hasOwnProperty,a=function(t,r){function e(){this.constructor=t}for(var n in r)l.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t};e=t("./SortedSet/AbstractSortedSet"),n=t("./SortedSet/ArrayStrategy"),o=t("./SortedSet/BinaryTreeStrategy"),i=t("./SortedSet/RedBlackTreeStrategy"),u=function(t){function r(t){t||(t={}),t.strategy||(t.strategy=i),t.comparator||(t.comparator=function(t,r){return(t||0)-(r||0)}),r.__super__.constructor.call(this,t)}return a(r,t),r}(e),u.ArrayStrategy=n,u.BinaryTreeStrategy=o,u.RedBlackTreeStrategy=i,r.exports=u},{"./SortedSet/AbstractSortedSet":3,"./SortedSet/ArrayStrategy":4,"./SortedSet/BinaryTreeStrategy":6,"./SortedSet/RedBlackTreeStrategy":7}],2:[function(t,r){var e,n,o;n=t("./BinaryTreeIterator"),o=function(t,r){return null!==t&&(o(t.left,r),r(t.value),o(t.right,r)),void 0},e=function(){function t(){}return t.prototype.toArray=function(){var t;return t=[],o(this.root,function(r){return t.push(r)}),t},t.prototype.forEachImpl=function(t,r,e){var n;return n=0,o(this.root,function(o){return t.call(e,o,n,r),n+=1}),void 0},t.prototype.contains=function(t){var r,e,n;for(e=this.comparator,n=this.root;null!==n&&(r=e(t,n.value),0!==r);)n=0>r?n.left:n.right;return null!==n&&n.value===t},t.prototype.findIterator=function(t){return n.find(this,t,this.comparator)},t.prototype.beginIterator=function(){return n.left(this)},t.prototype.endIterator=function(){return n.right(this)},t}(),r.exports=e},{"./BinaryTreeIterator":5}],3:[function(t,r){var e;r.exports=e=function(){function t(t){if(null==(null!=t?t.strategy:void 0))throw"Must pass options.strategy, a strategy";if(null==(null!=t?t.comparator:void 0))throw"Must pass options.comparator, a comparator";this.priv=new t.strategy(t),this.length=0}return t.prototype.insert=function(t){return this.priv.insert(t),this.length+=1,this},t.prototype.remove=function(t){return this.priv.remove(t),this.length-=1,this},t.prototype.contains=function(t){return this.priv.contains(t)},t.prototype.toArray=function(){return this.priv.toArray()},t.prototype.forEach=function(t,r){return this.priv.forEachImpl(t,this,r),this},t.prototype.map=function(t,r){var e;return e=[],this.forEach(function(n,o,i){return e.push(t.call(r,n,o,i))}),e},t.prototype.filter=function(t,r){var e;return e=[],this.forEach(function(n,o,i){return t.call(r,n,o,i)?e.push(n):void 0}),e},t.prototype.every=function(t,r){var e;return e=!0,this.forEach(function(n,o,i){return e&&!t.call(r,n,o,i)?e=!1:void 0}),e},t.prototype.some=function(t,r){var e;return e=!1,this.forEach(function(n,o,i){return!e&&t.call(r,n,o,i)?e=!0:void 0}),e},t.prototype.findIterator=function(t){return this.priv.findIterator(t)},t.prototype.beginIterator=function(){return this.priv.beginIterator()},t.prototype.endIterator=function(){return this.priv.endIterator()},t}()},{}],4:[function(t,r){var e,n,o;n=function(){function t(t,r){this.priv=t,this.index=r,this.data=this.priv.data}return t.prototype.hasNext=function(){return this.index<this.data.length},t.prototype.hasPrevious=function(){return this.index>0},t.prototype.value=function(){return this.index<this.data.length?this.data[this.index]:null},t.prototype.setValue=function(t){if(!this.priv.options.allowSetValue)throw"Must set options.allowSetValue";if(!this.hasNext())throw"Cannot set value at end of set";return this.data[this.index]=t},t.prototype.next=function(){return this.index>=this.data.length?null:new t(this.priv,this.index+1)},t.prototype.previous=function(){return this.index<=0?null:new t(this.priv,this.index-1)},t}(),o=function(t,r,e){var n,o,i;for(o=0,n=t.length;n>o;)i=o+n>>>1,e(t[i],r)<0?o=i+1:n=i;return o},e=function(){function t(t){this.options=t,this.comparator=this.options.comparator,this.data=[]}return t.prototype.toArray=function(){return this.data},t.prototype.insert=function(t){var r;if(r=o(this.data,t,this.comparator),this.data[r]===t)throw"Value already in set";return this.data.splice(r,0,t)},t.prototype.remove=function(t){var r;if(r=o(this.data,t,this.comparator),this.data[r]!==t)throw"Value not in set";return this.data.splice(r,1)},t.prototype.contains=function(t){var r;return r=o(this.data,t,this.comparator),this.index!==this.data.length&&this.data[r]===t},t.prototype.forEachImpl=function(t,r,e){var n,o,i,u,l;for(l=this.data,n=i=0,u=l.length;u>i;n=++i)o=l[n],t.call(e,o,n,r);return void 0},t.prototype.findIterator=function(t){var r;return r=o(this.data,t,this.comparator),new n(this,r)},t.prototype.beginIterator=function(){return new n(this,0)},t.prototype.endIterator=function(){return new n(this,this.data.length)},t}(),r.exports=e},{}],5:[function(t,r){var e,n,o;n=function(t,r){for(var e;null!==r[t];)e=r,r=r[t],r._iteratorParentNode=e;return r},o=function(t,r){var e,o;if(null!==r[t])e=r,r=r[t],r._iteratorParentNode=e,o="left"===t?"right":"left",r=n(o,r);else{for(;null!==(e=r._iteratorParentNode)&&e[t]===r;)r=e;r=e}return r},e=function(){function t(t,r){this.tree=t,this.node=r}return t.prototype.next=function(){var r;return null===this.node?null:(r=o("right",this.node),new t(this.tree,r))},t.prototype.previous=function(){var r;return null===this.node?null===this.tree.root?null:(this.tree.root._iteratorParentNode=null,r=n("right",this.tree.root),new t(this.tree,r)):(r=o("left",this.node),null===r?null:new t(this.tree,r))},t.prototype.hasNext=function(){return null!==this.node},t.prototype.hasPrevious=function(){return null!==this.previous()},t.prototype.value=function(){return null===this.node?null:this.node.value},t.prototype.setValue=function(t){if(!this.tree.options.allowSetValue)throw"Must set options.allowSetValue";if(!this.hasNext())throw"Cannot set value at end of set";return this.node.value=t},t}(),e.find=function(t,r,n){var o,i,u,l;for(l=t.root,null!=l&&(l._iteratorParentNode=null),u=l,i=null;null!==u&&(o=n(r,u.value),0!==o);)if(0>o){if(null===u.left)break;i=u,u.left._iteratorParentNode=u,u=u.left}else{if(null===u.right){u=i;break}u.right._iteratorParentNode=u,u=u.right}return new e(t,u)},e.left=function(t){var r;return null===t.root?new e(t,null):(t.root._iteratorParentNode=null,r=n("left",t.root),new e(t,r))},e.right=function(t){return new e(t,null)},r.exports=e},{}],6:[function(t,r){var e,n,o,i,u,l={}.hasOwnProperty,a=function(t,r){function e(){this.constructor=t}for(var n in r)l.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t};e=t("./AbstractBinaryTreeStrategy"),o=function(){function t(t){this.value=t,this.left=null,this.right=null}return t}(),u=function(t,r){for(;null!==t[r];)t=t[r];return t},i=function(t,r,e){var n,o;if(null===t)throw"Value not in set";return n=e(r,t.value),0>n?t.left=i(t.left,r,e):n>0?t.right=i(t.right,r,e):null===t.left&&null===t.right?t=null:null===t.right?t=t.left:null===t.left?t=t.right:(o=u(t.right,"left"),t.value=o.value,t.right=i(t.right,o.value,e)),t},n=function(t){function r(t){this.options=t,this.comparator=this.options.comparator,this.root=null}return a(r,t),r.prototype.insert=function(t){var r,e,n,i;if(e=this.comparator,null!=this.root){for(i=this.root;;){if(r=e(t,i.value),0===r)throw"Value already in set";if(n=0>r?"left":"right",null===i[n])break;i=i[n]}return i[n]=new o(t)}return this.root=new o(t)},r.prototype.remove=function(t){return this.root=i(this.root,t,this.comparator)},r}(e),r.exports=n},{"./AbstractBinaryTreeStrategy":2}],7:[function(t,r){var e,n,o,i,u,l,a,s,f,h,p,c,d,y={}.hasOwnProperty,v=function(t,r){function e(){this.constructor=t}for(var n in r)y.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t};e=t("./AbstractBinaryTreeStrategy"),n=function(){function t(t){this.value=t,this.left=null,this.right=null,this.isRed=!0}return t}(),c=function(t){var r;return r=t.right,t.right=r.left,r.left=t,r.isRed=t.isRed,t.isRed=!0,r},d=function(t){var r;return r=t.left,t.left=r.right,r.right=t,r.isRed=t.isRed,t.isRed=!0,r},i=function(t){return t.isRed=!t.isRed,t.left.isRed=!t.left.isRed,t.right.isRed=!t.right.isRed,void 0},s=function(t){return i(t),null!==t.right&&null!==t.right.left&&t.right.left.isRed&&(t.right=d(t.right),t=c(t),i(t)),t},f=function(t){return i(t),null!==t.left&&null!==t.left.left&&t.left.left.isRed&&(t=d(t),i(t)),t},a=function(t,r,e){if(null===t)return new n(r);if(t.value===r)throw"Value already in set";return e(r,t.value)<0?t.left=a(t.left,r,e):t.right=a(t.right,r,e),null===t.right||!t.right.isRed||null!==t.left&&t.left.isRed||(t=c(t)),null!==t.left&&t.left.isRed&&null!==t.left.left&&t.left.left.isRed&&(t=d(t)),null!==t.left&&t.left.isRed&&null!==t.right&&t.right.isRed&&i(t),t},u=function(t){for(;null!==t.left;)t=t.left;return t},l=function(t){return null!==t.right&&t.right.isRed&&(t=c(t)),null!==t.left&&t.left.isRed&&null!==t.left.left&&t.left.left.isRed&&(t=d(t)),null!==t.left&&t.left.isRed&&null!==t.right&&t.right.isRed&&i(t),t},p=function(t){return null===t.left?null:(t.left.isRed||null!==t.left.left&&t.left.left.isRed||(t=s(t)),t.left=p(t.left),l(t))},h=function(t,r,e){if(null===t)throw"Value not in set";if(t.value!==r&&e(r,t.value)<0){if(null===t.left)throw"Value not in set";t.left.isRed||null!==t.left.left&&t.left.left.isRed||(t=s(t)),t.left=h(t.left,r,e)}else{if(null!==t.left&&t.left.isRed&&(t=d(t)),null===t.right){if(r===t.value)return null;throw"Value not in set"}t.right.isRed||null!==t.right.left&&t.right.left.isRed||(t=f(t)),r===t.value?(t.value=u(t.right).value,t.right=p(t.right)):t.right=h(t.right,r,e)}return null!==t&&(t=l(t)),t},r.exports=o=function(t){function r(t){this.options=t,this.comparator=this.options.comparator,this.root=null}return v(r,t),r.prototype.insert=function(t){return this.root=a(this.root,t,this.comparator),this.root.isRed=!1,void 0},r.prototype.remove=function(t){return this.root=h(this.root,t,this.comparator),null!==this.root&&(this.root.isRed=!1),void 0},r}(e)},{"./AbstractBinaryTreeStrategy":2}]},{},[1])(1)}); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.SortedSet=t()}}(function(){return function t(r,e,n){function o(u,l){if(!e[u]){if(!r[u]){var a="function"==typeof require&&require;if(!l&&a)return a(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var f=e[u]={exports:{}};r[u][0].call(f.exports,function(t){var e=r[u][1][t];return o(e?e:t)},f,f.exports,t,r,e,n)}return e[u].exports}for(var i="function"==typeof require&&require,u=0;u<n.length;u++)o(n[u]);return o}({1:[function(t,r,e){var n,o,i,u,l,a=function(t,r){function e(){this.constructor=t}for(var n in r)s.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},s={}.hasOwnProperty;n=t("./SortedSet/AbstractSortedSet"),o=t("./SortedSet/ArrayStrategy"),i=t("./SortedSet/BinaryTreeStrategy"),u=t("./SortedSet/RedBlackTreeStrategy"),l=function(t){function r(t){t||(t={}),t.strategy||(t.strategy=u),t.comparator||(t.comparator=function(t,r){return(t||0)-(r||0)}),r.__super__.constructor.call(this,t)}return a(r,t),r}(n),l.ArrayStrategy=o,l.BinaryTreeStrategy=i,l.RedBlackTreeStrategy=u,r.exports=l},{"./SortedSet/AbstractSortedSet":3,"./SortedSet/ArrayStrategy":4,"./SortedSet/BinaryTreeStrategy":6,"./SortedSet/RedBlackTreeStrategy":7}],2:[function(t,r,e){var n,o,i;o=t("./BinaryTreeIterator"),i=function(t,r){return void(null!==t&&(i(t.left,r),r(t.value),i(t.right,r)))},n=function(){function t(){}return t.prototype.toArray=function(){var t;return t=[],i(this.root,function(r){return t.push(r)}),t},t.prototype.clear=function(){return this.root=null},t.prototype.forEachImpl=function(t,r,e){var n;return n=0,void i(this.root,function(o){return t.call(e,o,n,r),n+=1})},t.prototype.contains=function(t){var r,e,n;for(e=this.comparator,n=this.root;null!==n&&(r=e(t,n.value),0!==r);)n=0>r?n.left:n.right;return null!==n&&n.value===t},t.prototype.findIterator=function(t){return o.find(this,t,this.comparator)},t.prototype.beginIterator=function(){return o.left(this)},t.prototype.endIterator=function(){return o.right(this)},t}(),r.exports=n},{"./BinaryTreeIterator":5}],3:[function(t,r,e){var n;r.exports=n=function(){function t(t){if(null==(null!=t?t.strategy:void 0))throw"Must pass options.strategy, a strategy";if(null==(null!=t?t.comparator:void 0))throw"Must pass options.comparator, a comparator";this.priv=new t.strategy(t),this.length=0}return t.prototype.insert=function(t){return this.priv.insert(t),this.length+=1,this},t.prototype.remove=function(t){return this.priv.remove(t),this.length-=1,this},t.prototype.clear=function(){return this.priv.clear(),this.length=0,this},t.prototype.contains=function(t){return this.priv.contains(t)},t.prototype.toArray=function(){return this.priv.toArray()},t.prototype.forEach=function(t,r){return this.priv.forEachImpl(t,this,r),this},t.prototype.map=function(t,r){var e;return e=[],this.forEach(function(n,o,i){return e.push(t.call(r,n,o,i))}),e},t.prototype.filter=function(t,r){var e;return e=[],this.forEach(function(n,o,i){return t.call(r,n,o,i)?e.push(n):void 0}),e},t.prototype.every=function(t,r){var e;return e=!0,this.forEach(function(n,o,i){return e&&!t.call(r,n,o,i)?e=!1:void 0}),e},t.prototype.some=function(t,r){var e;return e=!1,this.forEach(function(n,o,i){return!e&&t.call(r,n,o,i)?e=!0:void 0}),e},t.prototype.findIterator=function(t){return this.priv.findIterator(t)},t.prototype.beginIterator=function(){return this.priv.beginIterator()},t.prototype.endIterator=function(){return this.priv.endIterator()},t}()},{}],4:[function(t,r,e){var n,o,i;o=function(){function t(t,r){this.priv=t,this.index=r,this.data=this.priv.data}return t.prototype.hasNext=function(){return this.index<this.data.length},t.prototype.hasPrevious=function(){return this.index>0},t.prototype.value=function(){return this.index<this.data.length?this.data[this.index]:null},t.prototype.setValue=function(t){if(!this.priv.options.allowSetValue)throw"Must set options.allowSetValue";if(!this.hasNext())throw"Cannot set value at end of set";return this.data[this.index]=t},t.prototype.next=function(){return this.index>=this.data.length?null:new t(this.priv,this.index+1)},t.prototype.previous=function(){return this.index<=0?null:new t(this.priv,this.index-1)},t}(),i=function(t,r,e){var n,o,i;for(o=0,n=t.length;n>o;)i=o+n>>>1,e(t[i],r)<0?o=i+1:n=i;return o},n=function(){function t(t){this.options=t,this.comparator=this.options.comparator,this.data=[]}return t.prototype.toArray=function(){return this.data},t.prototype.insert=function(t){var r;if(r=i(this.data,t,this.comparator),this.data[r]===t)throw"Value already in set";return this.data.splice(r,0,t)},t.prototype.remove=function(t){var r;if(r=i(this.data,t,this.comparator),this.data[r]!==t)throw"Value not in set";return this.data.splice(r,1)},t.prototype.clear=function(){return this.data.length=0},t.prototype.contains=function(t){var r;return r=i(this.data,t,this.comparator),this.index!==this.data.length&&this.data[r]===t},t.prototype.forEachImpl=function(t,r,e){var n,o,i,u,l;for(u=this.data,o=n=0,i=u.length;i>n;o=++n)l=u[o],t.call(e,l,o,r);return void 0},t.prototype.findIterator=function(t){var r;return r=i(this.data,t,this.comparator),new o(this,r)},t.prototype.beginIterator=function(){return new o(this,0)},t.prototype.endIterator=function(){return new o(this,this.data.length)},t}(),r.exports=n},{}],5:[function(t,r,e){var n,o,i;o=function(t,r){for(var e;null!==r[t];)e=r,r=r[t],r._iteratorParentNode=e;return r},i=function(t,r){var e,n;if(null!==r[t])e=r,r=r[t],r._iteratorParentNode=e,n="left"===t?"right":"left",r=o(n,r);else{for(;null!==(e=r._iteratorParentNode)&&e[t]===r;)r=e;r=e}return r},n=function(){function t(t,r){this.tree=t,this.node=r}return t.prototype.next=function(){var r;return null===this.node?null:(r=i("right",this.node),new t(this.tree,r))},t.prototype.previous=function(){var r;return null===this.node?null===this.tree.root?null:(this.tree.root._iteratorParentNode=null,r=o("right",this.tree.root),new t(this.tree,r)):(r=i("left",this.node),null===r?null:new t(this.tree,r))},t.prototype.hasNext=function(){return null!==this.node},t.prototype.hasPrevious=function(){return null!==this.previous()},t.prototype.value=function(){return null===this.node?null:this.node.value},t.prototype.setValue=function(t){if(!this.tree.options.allowSetValue)throw"Must set options.allowSetValue";if(!this.hasNext())throw"Cannot set value at end of set";return this.node.value=t},t}(),n.find=function(t,r,e){var o,i,u,l;for(l=t.root,null!=l&&(l._iteratorParentNode=null),u=l,i=null;null!==u&&(o=e(r,u.value),0!==o);)if(0>o){if(null===u.left)break;i=u,u.left._iteratorParentNode=u,u=u.left}else{if(null===u.right){u=i;break}u.right._iteratorParentNode=u,u=u.right}return new n(t,u)},n.left=function(t){var r;return null===t.root?new n(t,null):(t.root._iteratorParentNode=null,r=o("left",t.root),new n(t,r))},n.right=function(t){return new n(t,null)},r.exports=n},{}],6:[function(t,r,e){var n,o,i,u,l,a=function(t,r){function e(){this.constructor=t}for(var n in r)s.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},s={}.hasOwnProperty;n=t("./AbstractBinaryTreeStrategy"),i=function(){function t(t){this.value=t,this.left=null,this.right=null}return t}(),l=function(t,r){for(;null!==t[r];)t=t[r];return t},u=function(t,r,e){var n,o;if(null===t)throw"Value not in set";return n=e(r,t.value),0>n?t.left=u(t.left,r,e):n>0?t.right=u(t.right,r,e):null===t.left&&null===t.right?t=null:null===t.right?t=t.left:null===t.left?t=t.right:(o=l(t.right,"left"),t.value=o.value,t.right=u(t.right,o.value,e)),t},o=function(t){function r(t){this.options=t,this.comparator=this.options.comparator,this.root=null}return a(r,t),r.prototype.insert=function(t){var r,e,n,o;if(e=this.comparator,null!=this.root){for(o=this.root;;){if(r=e(t,o.value),0===r)throw"Value already in set";if(n=0>r?"left":"right",null===o[n])break;o=o[n]}return o[n]=new i(t)}return this.root=new i(t)},r.prototype.remove=function(t){return this.root=u(this.root,t,this.comparator)},r}(n),r.exports=o},{"./AbstractBinaryTreeStrategy":2}],7:[function(t,r,e){var n,o,i,u,l,a,s,f,h,p,c,d,y,v=function(t,r){function e(){this.constructor=t}for(var n in r)g.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},g={}.hasOwnProperty;n=t("./AbstractBinaryTreeStrategy"),o=function(){function t(t){this.value=t,this.left=null,this.right=null,this.isRed=!0}return t}(),d=function(t){var r;return r=t.right,t.right=r.left,r.left=t,r.isRed=t.isRed,t.isRed=!0,r},y=function(t){var r;return r=t.left,t.left=r.right,r.right=t,r.isRed=t.isRed,t.isRed=!0,r},u=function(t){return t.isRed=!t.isRed,t.left.isRed=!t.left.isRed,void(t.right.isRed=!t.right.isRed)},f=function(t){return u(t),null!==t.right&&null!==t.right.left&&t.right.left.isRed&&(t.right=y(t.right),t=d(t),u(t)),t},h=function(t){return u(t),null!==t.left&&null!==t.left.left&&t.left.left.isRed&&(t=y(t),u(t)),t},s=function(t,r,e){if(null===t)return new o(r);if(t.value===r)throw"Value already in set";return e(r,t.value)<0?t.left=s(t.left,r,e):t.right=s(t.right,r,e),null===t.right||!t.right.isRed||null!==t.left&&t.left.isRed||(t=d(t)),null!==t.left&&t.left.isRed&&null!==t.left.left&&t.left.left.isRed&&(t=y(t)),null!==t.left&&t.left.isRed&&null!==t.right&&t.right.isRed&&u(t),t},l=function(t){for(;null!==t.left;)t=t.left;return t},a=function(t){return null!==t.right&&t.right.isRed&&(t=d(t)),null!==t.left&&t.left.isRed&&null!==t.left.left&&t.left.left.isRed&&(t=y(t)),null!==t.left&&t.left.isRed&&null!==t.right&&t.right.isRed&&u(t),t},c=function(t){return null===t.left?null:(t.left.isRed||null!==t.left.left&&t.left.left.isRed||(t=f(t)),t.left=c(t.left),a(t))},p=function(t,r,e){if(null===t)throw"Value not in set";if(t.value!==r&&e(r,t.value)<0){if(null===t.left)throw"Value not in set";t.left.isRed||null!==t.left.left&&t.left.left.isRed||(t=f(t)),t.left=p(t.left,r,e)}else{if(null!==t.left&&t.left.isRed&&(t=y(t)),null===t.right){if(r===t.value)return null;throw"Value not in set"}t.right.isRed||null!==t.right.left&&t.right.left.isRed||(t=h(t)),r===t.value?(t.value=l(t.right).value,t.right=c(t.right)):t.right=p(t.right,r,e)}return null!==t&&(t=a(t)),t},r.exports=i=function(t){function r(t){this.options=t,this.comparator=this.options.comparator,this.root=null}return v(r,t),r.prototype.insert=function(t){return this.root=s(this.root,t,this.comparator),void(this.root.isRed=!1)},r.prototype.remove=function(t){return this.root=p(this.root,t,this.comparator),void(null!==this.root&&(this.root.isRed=!1))},r}(n)},{"./AbstractBinaryTreeStrategy":2}]},{},[1])(1)}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71494
681
194
21