Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ss-linked-list

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ss-linked-list - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

16

CHANGELOG.md

@@ -5,2 +5,18 @@ # Change Log

<a name="1.1.3"></a>
## [1.1.3](https://github.com/boycgit/ss-linked-list/compare/v1.1.0...v1.1.3) (2018-10-22)
### Bug Fixes
* **fix:** fix null to void 0 , for value ([bb63b51](https://github.com/boycgit/ss-linked-list/commit/bb63b51))
* **依赖:** 去掉不必要的依赖 ([743c782](https://github.com/boycgit/ss-linked-list/commit/743c782))
### Features
* **功能重构:** 使用 ss-comparator 代替默认的对比函数 ([f9d1379](https://github.com/boycgit/ss-linked-list/commit/f9d1379))
<a name="1.1.0"></a>

@@ -7,0 +23,0 @@ # 1.1.0 (2018-09-05)

118

dist/index.cjs.js

@@ -108,2 +108,107 @@ 'use strict';

/**
* enumeration of compare result, there is only three state
*
* @export
* @enum {number}
*/
var CompareResult;
(function (CompareResult) {
CompareResult[CompareResult["EQUAL"] = 0] = "EQUAL";
CompareResult[CompareResult["GREATER"] = 1] = "GREATER";
CompareResult[CompareResult["LESS"] = -1] = "LESS";
})(CompareResult || (CompareResult = {}));
/**
* a class that describe how compares two object
*
* @export
* @class Comparator
*/
var Comparator = /** @class */ (function () {
/**
* Creates an instance of Comparator.
* @param {compareFunction} compareFunction - function that implement compare operation
* @memberof Comparator
*/
function Comparator(compareFunction) {
this.compare = compareFunction || Comparator.defaultCompareFunction;
}
/**
* @param {(string|number)} a - compare target a
* @param {(string|number)} b - compare target b
* @returns {number}
*/
Comparator.defaultCompareFunction = function (a, b) {
if (a === b) {
return CompareResult.EQUAL;
}
return a < b ? CompareResult.LESS : CompareResult.GREATER;
};
/**
* compare if equal or not, a === b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.equal = function (a, b) {
return this.compare(a, b) === CompareResult.EQUAL;
};
/**
* compare if smaller. a < b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.lessThan = function (a, b) {
return this.compare(a, b) === CompareResult.LESS;
};
/**
* compare if greater. a > b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.greaterThan = function (a, b) {
return this.compare(a, b) === CompareResult.GREATER;
};
/**
* compare if smaller or equal. a <= b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.lessThanOrEqual = function (a, b) {
return this.lessThan(a, b) || this.equal(a, b);
};
/**
* compare if greater or equal. a >= b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.greaterThanOrEqual = function (a, b) {
return this.greaterThan(a, b) || this.equal(a, b);
};
/**
* reverse the compare function
*
* @memberof Comparator
*/
Comparator.prototype.reverse = function () {
var compareOriginal = this.compare;
this.compare = function (a, b) { return compareOriginal(b, a); };
};
return Comparator;
}());
var List = /** @class */ (function () {

@@ -119,2 +224,3 @@ function List() {

this._length = 0;
this.compare = new Comparator();
if (values.length > 0) {

@@ -205,3 +311,3 @@ values.forEach(function (value) {

count++;
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
return count;

@@ -212,3 +318,3 @@ }

// 如果是末尾节点,需要额外处理
if (currentNode === this._tail && currentNode.value === val) {
if (currentNode === this._tail && this.compare.equal(currentNode.value, val)) {
count += 1;

@@ -300,3 +406,3 @@ }

}
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
// 这里需要注意,有两种情况:

@@ -318,3 +424,3 @@ if (currentNode.next) {

while (true) {
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
if (currentNode.next) {

@@ -586,3 +692,3 @@ prevNode.next = currentNode.next;

// 当首个元素恰好是目标值的时候
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
// 这里需要注意,有两种情况:

@@ -604,3 +710,3 @@ if (currentNode.next) {

while (true) {
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
if (currentNode.next) {

@@ -607,0 +713,0 @@ // special case for last element

2

dist/index.cjs.min.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var SinglyNode=function(t){this.value=t,this.next=null},DoublyNode=function(t){this.value=t,this.next=null,this.prev=null},extendStatics=function(t,e){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function __extends(t,e){function r(){this.constructor=t}extendStatics(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function __generator(r,n){var i,o,a,t,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;l;)try{if(i=1,o&&(a=2&e[0]?o.return:e[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,e[1])).done)return a;switch(o=0,a&&(e=[2&e[0],a.value]),e[0]){case 0:case 1:a=e;break;case 4:return l.label++,{value:e[1],done:!1};case 5:l.label++,o=e[1],e=[0];continue;case 7:e=l.ops.pop(),l.trys.pop();continue;default:if(!(a=0<(a=l.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){l=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){l.label=e[1];break}if(6===e[0]&&l.label<a[1]){l.label=a[1],a=e;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(e);break}a[2]&&l.ops.pop(),l.trys.pop();continue}e=n.call(r,l)}catch(t){e=[6,t],o=0}finally{i=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function __read(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||0<e--)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function __spread(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(__read(arguments[e]));return t}var OBFUSCATED_ERROR="obfuse error occur";function invariant(t,e){if(!t)throw new Error("[linked-list] "+(e||OBFUSCATED_ERROR))}var INDEX_NOT_FOUND=-1,List=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=this;this._head=null,this._tail=null,(this._length=0)<t.length&&t.forEach(function(t){r.append(t)})}return Object.defineProperty(t.prototype,"head",{get:function(){return this._head?this._head.value:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"tail",{get:function(){return this._tail?this._tail.value:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this._length},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"loopLength",{get:function(){var t=!1,e=1;if(!this._head)return 0;for(var r=this._head,n=this._head;n.next&&n.next.next;)if(n=n.next.next,(r=r.next)===n){t=!0;break}if(t){for(n=n.next;r!==n;)e++,n=n.next;return e}return 0},enumerable:!0,configurable:!0}),t.prototype.getNode=function(t){var e=this._length;invariant(0<e&&0<=t&&t<e,"[linked-list] index "+t+" out of scope of list, which length is "+e);for(var r=this._head,n=0;n<t;)r=r.next,n++;return r},t.prototype.get=function(t){var e=this.getNode(t);return e?e.value:null},t.prototype.indexOf=function(t){if(!this._head)return INDEX_NOT_FOUND;for(var e=this._head,r=-1;e.next;){if(r++,e.value===t)return r;e=e.next}return e===this._tail&&e.value===t&&(r+=1),r},t.prototype.first=function(t){invariant(0<=t,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.iterator(),r=[],n=Math.min(t,this.length),i=0;i<n;i++){var o=e.next();r.push(o.value)}return r},t.prototype.toArray=function(){return __spread(this)},t.prototype.isEmpty=function(){return null===this._head},t.prototype.iterator=function(){var e;return __generator(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})},t.prototype[Symbol.iterator]=function(){return this.iterator()},t}(),SinglyList=function(r){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.apply(this,__spread(t))||this}return __extends(e,r),e.prototype.append=function(t){var e=new SinglyNode(t);return this._tail?(this._tail.next=e,this._tail=e):this._head=this._tail=e,this._length++,!0},e.prototype.prepend=function(t){var e=new SinglyNode(t);return this._head?(e.next=this._head,this._head=e):this._head=this._tail=e,this._length++,!0},e.prototype.remove=function(t){var e=this._head;if(e){if(e.value===t)return e.next?(this._head=e.next,e.next=null):this._head=this._tail=null,this._length--,t;for(var r=e;;){if(e.value===t)return e.next?r.next=e.next:(this._tail=r,this._tail.next=null),e.next=null,this._length--,t;if(!e.next)return;e=(r=e).next}}},e.prototype.removeHead=function(){var t=this._head;if(t)return this._head.next?(this._head=t.next,t.next=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.removeTail=function(){var t=this._tail;if(t){if(this._head.next){for(var e=this._head;e.next!==t;)e=e.next;e.next=null,this._tail=e}else this._head=null,this._tail=null;return this._length--,t.value}},e.prototype.reverse=function(){if(this._head){var t,e=this._head,r=null;for(this._tail=this._head;null!==e;)t=e.next,e.next=r,r=e,e=t;this._head=r}},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(List),AbstractCircleSinglyList=function(i){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=i.apply(this,__spread(t))||this;return r.cyclization(),r}return __extends(t,i),t.prototype.iterator=function(){var e;return __generator(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),(e=e.next)===this._head&&(e=null),[3,1];case 3:return[2]}})},t.prototype.circleIterator=function(){var e;return __generator(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})},t.prototype[Symbol.iterator]=function(){return this.iterator()},t.prototype.mapToNormalListFn=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.breakCircle();var n=i.prototype[t].apply(this,e);return this.cyclization(),n},t.prototype.getNode=function(t){return this.mapToNormalListFn("getNode",t)},t.prototype.append=function(t){return this.mapToNormalListFn("append",t)},t.prototype.prepend=function(t){return this.mapToNormalListFn("prepend",t)},t.prototype.indexOf=function(t){return this.mapToNormalListFn("indexOf",t)},t.prototype.remove=function(t){return this.mapToNormalListFn("remove",t)},t.prototype.removeHead=function(){return this.mapToNormalListFn("removeHead")},t.prototype.removeTail=function(){return this.mapToNormalListFn("removeTail")},t.prototype.first=function(t){invariant(0<=t,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.circleIterator(),r=[],n=0;n<t;n++){var i=e.next();r.push(i.value)}return r},t.prototype.toArray=function(){return this.mapToNormalListFn("toArray")},t.prototype.reverse=function(){return this.mapToNormalListFn("reverse")},t}(SinglyList),CircleSinglyList=function(n){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=n.apply(this,__spread(t))||this;return r.cyclization(),r}return __extends(e,n),e.prototype.breakCircle=function(){this._tail&&this._tail.next===this._head&&(this._tail.next=null)},e.prototype.cyclization=function(){this._tail&&null===this._tail.next&&(this._tail.next=this._head)},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(AbstractCircleSinglyList),DoublyList=function(r){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.apply(this,__spread(t))||this}return __extends(e,r),e.prototype.append=function(t){var e=new DoublyNode(t);return this._tail?((this._tail.next=e).prev=this._tail,this._tail=e):this._head=this._tail=e,this._length++,!0},e.prototype.prepend=function(t){var e=new DoublyNode(t);return this._head?(e.next=this._head,this._head.prev=e,this._head=e):this._head=this._tail=e,this._length++,!0},e.prototype.remove=function(t){var e=this._head;if(e){if(e.value===t)return e.next?(this._head=e.next,this._head.prev=null,e.next=e.prev=null):this._head=this._tail=null,this._length--,t;for(;;){if(e.value===t)return e.next?(e.prev.next=e.next,e.next.prev=e.prev):(e.prev.next=null,this._tail=e.prev),e.next=e.prev=null,this._length--,e.value;if(!e.next)return;e=e.next}}},e.prototype.removeHead=function(){var t=this._head;if(t)return this._head.next?(t.next.prev=null,this._head=t.next,t.next=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.removeTail=function(){var t=this._tail;if(t)return this._head.next?(t.prev.next=null,this._tail=t.prev,t.next=t.prev=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.reverse=function(){if(this._head){var t,e=this._head,r=null;for(this._tail=this._head;null!==e;)t=e.next,e.next=r,e.prev=t,r=e,e=t;this._head=r}},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(List),AbstractCircleDoublyList=function(i){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=i.apply(this,__spread(t))||this;return r.cyclization(),r}return __extends(t,i),t.prototype.iterator=function(){var e;return __generator(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),(e=e.next)===this._head&&(e=null),[3,1];case 3:return[2]}})},t.prototype.circleIterator=function(){var e;return __generator(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})},t.prototype[Symbol.iterator]=function(){return this.iterator()},t.prototype.mapToNormalListFn=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.breakCircle();var n=i.prototype[t].apply(this,e);return this.cyclization(),n},t.prototype.getNode=function(t){return this.mapToNormalListFn("getNode",t)},t.prototype.append=function(t){return this.mapToNormalListFn("append",t)},t.prototype.prepend=function(t){return this.mapToNormalListFn("prepend",t)},t.prototype.indexOf=function(t){return this.mapToNormalListFn("indexOf",t)},t.prototype.remove=function(t){return this.mapToNormalListFn("remove",t)},t.prototype.removeHead=function(){return this.mapToNormalListFn("removeHead")},t.prototype.removeTail=function(){return this.mapToNormalListFn("removeTail")},t.prototype.first=function(t){invariant(0<=t,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.circleIterator(),r=[],n=0;n<t;n++){var i=e.next();r.push(i.value)}return r},t.prototype.toArray=function(){return this.mapToNormalListFn("toArray")},t.prototype.reverse=function(){return this.mapToNormalListFn("reverse")},t}(DoublyList),CircleDoublyList=function(n){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=n.apply(this,__spread(t))||this;return r.cyclization(),r}return __extends(e,n),e.prototype.breakCircle=function(){this._tail&&this._head&&this._tail.next===this._head&&(this._tail.next=null,this._head.prev=null)},e.prototype.cyclization=function(){this._head&&this._tail&&null===this._tail.next&&(this._tail.next=this._head,this._head.prev=this._tail)},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(AbstractCircleDoublyList);exports.SinglyNode=SinglyNode,exports.DoublyNode=DoublyNode,exports.SinglyList=SinglyList,exports.AbstractCircleSinglyList=AbstractCircleSinglyList,exports.CircleSinglyList=CircleSinglyList,exports.DoublyList=DoublyList,exports.AbstractCircleDoublyList=AbstractCircleDoublyList,exports.CircleDoublyList=CircleDoublyList;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var SinglyNode=function(t){this.value=t,this.next=null},DoublyNode=function(t){this.value=t,this.next=null,this.prev=null},extendStatics=function(t,e){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function __extends(t,e){function r(){this.constructor=t}extendStatics(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function __generator(r,n){var i,o,a,t,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;l;)try{if(i=1,o&&(a=2&e[0]?o.return:e[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,e[1])).done)return a;switch(o=0,a&&(e=[2&e[0],a.value]),e[0]){case 0:case 1:a=e;break;case 4:return l.label++,{value:e[1],done:!1};case 5:l.label++,o=e[1],e=[0];continue;case 7:e=l.ops.pop(),l.trys.pop();continue;default:if(!(a=0<(a=l.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){l=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){l.label=e[1];break}if(6===e[0]&&l.label<a[1]){l.label=a[1],a=e;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(e);break}a[2]&&l.ops.pop(),l.trys.pop();continue}e=n.call(r,l)}catch(t){e=[6,t],o=0}finally{i=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function __read(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||0<e--)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function __spread(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(__read(arguments[e]));return t}var OBFUSCATED_ERROR="obfuse error occur";function invariant(t,e){if(!t)throw new Error("[linked-list] "+(e||OBFUSCATED_ERROR))}var CompareResult,INDEX_NOT_FOUND=-1;!function(t){t[t.EQUAL=0]="EQUAL",t[t.GREATER=1]="GREATER",t[t.LESS=-1]="LESS"}(CompareResult||(CompareResult={}));var Comparator=function(){function e(t){this.compare=t||e.defaultCompareFunction}return e.defaultCompareFunction=function(t,e){return t===e?CompareResult.EQUAL:t<e?CompareResult.LESS:CompareResult.GREATER},e.prototype.equal=function(t,e){return this.compare(t,e)===CompareResult.EQUAL},e.prototype.lessThan=function(t,e){return this.compare(t,e)===CompareResult.LESS},e.prototype.greaterThan=function(t,e){return this.compare(t,e)===CompareResult.GREATER},e.prototype.lessThanOrEqual=function(t,e){return this.lessThan(t,e)||this.equal(t,e)},e.prototype.greaterThanOrEqual=function(t,e){return this.greaterThan(t,e)||this.equal(t,e)},e.prototype.reverse=function(){var r=this.compare;this.compare=function(t,e){return r(e,t)}},e}(),List=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=this;this._head=null,this._tail=null,this._length=0,this.compare=new Comparator,0<t.length&&t.forEach(function(t){r.append(t)})}return Object.defineProperty(t.prototype,"head",{get:function(){return this._head?this._head.value:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"tail",{get:function(){return this._tail?this._tail.value:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this._length},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"loopLength",{get:function(){var t=!1,e=1;if(!this._head)return 0;for(var r=this._head,n=this._head;n.next&&n.next.next;)if(n=n.next.next,(r=r.next)===n){t=!0;break}if(t){for(n=n.next;r!==n;)e++,n=n.next;return e}return 0},enumerable:!0,configurable:!0}),t.prototype.getNode=function(t){var e=this._length;invariant(0<e&&0<=t&&t<e,"[linked-list] index "+t+" out of scope of list, which length is "+e);for(var r=this._head,n=0;n<t;)r=r.next,n++;return r},t.prototype.get=function(t){var e=this.getNode(t);return e?e.value:null},t.prototype.indexOf=function(t){if(!this._head)return INDEX_NOT_FOUND;for(var e=this._head,r=-1;e.next;){if(r++,this.compare.equal(e.value,t))return r;e=e.next}return e===this._tail&&this.compare.equal(e.value,t)&&(r+=1),r},t.prototype.first=function(t){invariant(0<=t,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.iterator(),r=[],n=Math.min(t,this.length),i=0;i<n;i++){var o=e.next();r.push(o.value)}return r},t.prototype.toArray=function(){return __spread(this)},t.prototype.isEmpty=function(){return null===this._head},t.prototype.iterator=function(){var e;return __generator(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})},t.prototype[Symbol.iterator]=function(){return this.iterator()},t}(),SinglyList=function(r){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.apply(this,__spread(t))||this}return __extends(e,r),e.prototype.append=function(t){var e=new SinglyNode(t);return this._tail?(this._tail.next=e,this._tail=e):this._head=this._tail=e,this._length++,!0},e.prototype.prepend=function(t){var e=new SinglyNode(t);return this._head?(e.next=this._head,this._head=e):this._head=this._tail=e,this._length++,!0},e.prototype.remove=function(t){var e=this._head;if(e){if(this.compare.equal(e.value,t))return e.next?(this._head=e.next,e.next=null):this._head=this._tail=null,this._length--,t;for(var r=e;;){if(this.compare.equal(e.value,t))return e.next?r.next=e.next:(this._tail=r,this._tail.next=null),e.next=null,this._length--,t;if(!e.next)return;e=(r=e).next}}},e.prototype.removeHead=function(){var t=this._head;if(t)return this._head.next?(this._head=t.next,t.next=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.removeTail=function(){var t=this._tail;if(t){if(this._head.next){for(var e=this._head;e.next!==t;)e=e.next;e.next=null,this._tail=e}else this._head=null,this._tail=null;return this._length--,t.value}},e.prototype.reverse=function(){if(this._head){var t,e=this._head,r=null;for(this._tail=this._head;null!==e;)t=e.next,e.next=r,r=e,e=t;this._head=r}},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(List),AbstractCircleSinglyList=function(i){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=i.apply(this,__spread(t))||this;return r.cyclization(),r}return __extends(t,i),t.prototype.iterator=function(){var e;return __generator(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),(e=e.next)===this._head&&(e=null),[3,1];case 3:return[2]}})},t.prototype.circleIterator=function(){var e;return __generator(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})},t.prototype[Symbol.iterator]=function(){return this.iterator()},t.prototype.mapToNormalListFn=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.breakCircle();var n=i.prototype[t].apply(this,e);return this.cyclization(),n},t.prototype.getNode=function(t){return this.mapToNormalListFn("getNode",t)},t.prototype.append=function(t){return this.mapToNormalListFn("append",t)},t.prototype.prepend=function(t){return this.mapToNormalListFn("prepend",t)},t.prototype.indexOf=function(t){return this.mapToNormalListFn("indexOf",t)},t.prototype.remove=function(t){return this.mapToNormalListFn("remove",t)},t.prototype.removeHead=function(){return this.mapToNormalListFn("removeHead")},t.prototype.removeTail=function(){return this.mapToNormalListFn("removeTail")},t.prototype.first=function(t){invariant(0<=t,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.circleIterator(),r=[],n=0;n<t;n++){var i=e.next();r.push(i.value)}return r},t.prototype.toArray=function(){return this.mapToNormalListFn("toArray")},t.prototype.reverse=function(){return this.mapToNormalListFn("reverse")},t}(SinglyList),CircleSinglyList=function(n){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=n.apply(this,__spread(t))||this;return r.cyclization(),r}return __extends(e,n),e.prototype.breakCircle=function(){this._tail&&this._tail.next===this._head&&(this._tail.next=null)},e.prototype.cyclization=function(){this._tail&&null===this._tail.next&&(this._tail.next=this._head)},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(AbstractCircleSinglyList),DoublyList=function(r){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.apply(this,__spread(t))||this}return __extends(e,r),e.prototype.append=function(t){var e=new DoublyNode(t);return this._tail?((this._tail.next=e).prev=this._tail,this._tail=e):this._head=this._tail=e,this._length++,!0},e.prototype.prepend=function(t){var e=new DoublyNode(t);return this._head?(e.next=this._head,this._head.prev=e,this._head=e):this._head=this._tail=e,this._length++,!0},e.prototype.remove=function(t){var e=this._head;if(e){if(this.compare.equal(e.value,t))return e.next?(this._head=e.next,this._head.prev=null,e.next=e.prev=null):this._head=this._tail=null,this._length--,t;for(;;){if(this.compare.equal(e.value,t))return e.next?(e.prev.next=e.next,e.next.prev=e.prev):(e.prev.next=null,this._tail=e.prev),e.next=e.prev=null,this._length--,e.value;if(!e.next)return;e=e.next}}},e.prototype.removeHead=function(){var t=this._head;if(t)return this._head.next?(t.next.prev=null,this._head=t.next,t.next=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.removeTail=function(){var t=this._tail;if(t)return this._head.next?(t.prev.next=null,this._tail=t.prev,t.next=t.prev=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.reverse=function(){if(this._head){var t,e=this._head,r=null;for(this._tail=this._head;null!==e;)t=e.next,e.next=r,e.prev=t,r=e,e=t;this._head=r}},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(List),AbstractCircleDoublyList=function(i){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=i.apply(this,__spread(t))||this;return r.cyclization(),r}return __extends(t,i),t.prototype.iterator=function(){var e;return __generator(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),(e=e.next)===this._head&&(e=null),[3,1];case 3:return[2]}})},t.prototype.circleIterator=function(){var e;return __generator(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})},t.prototype[Symbol.iterator]=function(){return this.iterator()},t.prototype.mapToNormalListFn=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.breakCircle();var n=i.prototype[t].apply(this,e);return this.cyclization(),n},t.prototype.getNode=function(t){return this.mapToNormalListFn("getNode",t)},t.prototype.append=function(t){return this.mapToNormalListFn("append",t)},t.prototype.prepend=function(t){return this.mapToNormalListFn("prepend",t)},t.prototype.indexOf=function(t){return this.mapToNormalListFn("indexOf",t)},t.prototype.remove=function(t){return this.mapToNormalListFn("remove",t)},t.prototype.removeHead=function(){return this.mapToNormalListFn("removeHead")},t.prototype.removeTail=function(){return this.mapToNormalListFn("removeTail")},t.prototype.first=function(t){invariant(0<=t,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.circleIterator(),r=[],n=0;n<t;n++){var i=e.next();r.push(i.value)}return r},t.prototype.toArray=function(){return this.mapToNormalListFn("toArray")},t.prototype.reverse=function(){return this.mapToNormalListFn("reverse")},t}(DoublyList),CircleDoublyList=function(n){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=n.apply(this,__spread(t))||this;return r.cyclization(),r}return __extends(e,n),e.prototype.breakCircle=function(){this._tail&&this._head&&this._tail.next===this._head&&(this._tail.next=null,this._head.prev=null)},e.prototype.cyclization=function(){this._head&&this._tail&&null===this._tail.next&&(this._tail.next=this._head,this._head.prev=this._tail)},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(AbstractCircleDoublyList);exports.SinglyNode=SinglyNode,exports.DoublyNode=DoublyNode,exports.SinglyList=SinglyList,exports.AbstractCircleSinglyList=AbstractCircleSinglyList,exports.CircleSinglyList=CircleSinglyList,exports.DoublyList=DoublyList,exports.AbstractCircleDoublyList=AbstractCircleDoublyList,exports.CircleDoublyList=CircleDoublyList;

@@ -104,2 +104,107 @@ var SinglyNode = /** @class */ (function () {

/**
* enumeration of compare result, there is only three state
*
* @export
* @enum {number}
*/
var CompareResult;
(function (CompareResult) {
CompareResult[CompareResult["EQUAL"] = 0] = "EQUAL";
CompareResult[CompareResult["GREATER"] = 1] = "GREATER";
CompareResult[CompareResult["LESS"] = -1] = "LESS";
})(CompareResult || (CompareResult = {}));
/**
* a class that describe how compares two object
*
* @export
* @class Comparator
*/
var Comparator = /** @class */ (function () {
/**
* Creates an instance of Comparator.
* @param {compareFunction} compareFunction - function that implement compare operation
* @memberof Comparator
*/
function Comparator(compareFunction) {
this.compare = compareFunction || Comparator.defaultCompareFunction;
}
/**
* @param {(string|number)} a - compare target a
* @param {(string|number)} b - compare target b
* @returns {number}
*/
Comparator.defaultCompareFunction = function (a, b) {
if (a === b) {
return CompareResult.EQUAL;
}
return a < b ? CompareResult.LESS : CompareResult.GREATER;
};
/**
* compare if equal or not, a === b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.equal = function (a, b) {
return this.compare(a, b) === CompareResult.EQUAL;
};
/**
* compare if smaller. a < b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.lessThan = function (a, b) {
return this.compare(a, b) === CompareResult.LESS;
};
/**
* compare if greater. a > b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.greaterThan = function (a, b) {
return this.compare(a, b) === CompareResult.GREATER;
};
/**
* compare if smaller or equal. a <= b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.lessThanOrEqual = function (a, b) {
return this.lessThan(a, b) || this.equal(a, b);
};
/**
* compare if greater or equal. a >= b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.greaterThanOrEqual = function (a, b) {
return this.greaterThan(a, b) || this.equal(a, b);
};
/**
* reverse the compare function
*
* @memberof Comparator
*/
Comparator.prototype.reverse = function () {
var compareOriginal = this.compare;
this.compare = function (a, b) { return compareOriginal(b, a); };
};
return Comparator;
}());
var List = /** @class */ (function () {

@@ -115,2 +220,3 @@ function List() {

this._length = 0;
this.compare = new Comparator();
if (values.length > 0) {

@@ -201,3 +307,3 @@ values.forEach(function (value) {

count++;
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
return count;

@@ -208,3 +314,3 @@ }

// 如果是末尾节点,需要额外处理
if (currentNode === this._tail && currentNode.value === val) {
if (currentNode === this._tail && this.compare.equal(currentNode.value, val)) {
count += 1;

@@ -296,3 +402,3 @@ }

}
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
// 这里需要注意,有两种情况:

@@ -314,3 +420,3 @@ if (currentNode.next) {

while (true) {
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
if (currentNode.next) {

@@ -582,3 +688,3 @@ prevNode.next = currentNode.next;

// 当首个元素恰好是目标值的时候
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
// 这里需要注意,有两种情况:

@@ -600,3 +706,3 @@ if (currentNode.next) {

while (true) {
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
if (currentNode.next) {

@@ -603,0 +709,0 @@ // special case for last element

@@ -1,1 +0,1 @@

var SinglyNode=function(){return function(t){this.value=t,this.next=null}}(),DoublyNode=function(){return function(t){this.value=t,this.next=null,this.prev=null}}(),extendStatics=function(t,e){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function __extends(t,e){function r(){this.constructor=t}extendStatics(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function __generator(t,e){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,l])}}}function __read(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function __spread(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(__read(arguments[e]));return t}var OBFUSCATED_ERROR="obfuse error occur";function invariant(t,e){if(!t)throw new Error("[linked-list] "+(e||OBFUSCATED_ERROR))}var INDEX_NOT_FOUND=-1,List=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=this;this._head=null,this._tail=null,this._length=0,t.length>0&&t.forEach(function(t){r.append(t)})}return Object.defineProperty(t.prototype,"head",{get:function(){return this._head?this._head.value:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"tail",{get:function(){return this._tail?this._tail.value:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this._length},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"loopLength",{get:function(){var t=!1,e=1;if(!this._head)return 0;for(var r=this._head,n=this._head;n.next&&n.next.next;)if(n=n.next.next,(r=r.next)===n){t=!0;break}if(t){for(n=n.next;r!==n;)e++,n=n.next;return e}return 0},enumerable:!0,configurable:!0}),t.prototype.getNode=function(t){var e=this._length;invariant(e>0&&t>=0&&t<e,"[linked-list] index "+t+" out of scope of list, which length is "+e);for(var r=this._head,n=0;n<t;)r=r.next,n++;return r},t.prototype.get=function(t){var e=this.getNode(t);return e?e.value:null},t.prototype.indexOf=function(t){if(!this._head)return INDEX_NOT_FOUND;for(var e=this._head,r=-1;e.next;){if(r++,e.value===t)return r;e=e.next}return e===this._tail&&e.value===t&&(r+=1),r},t.prototype.first=function(t){invariant(t>=0,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.iterator(),r=[],n=Math.min(t,this.length),i=0;i<n;i++){var o=e.next();r.push(o.value)}return r},t.prototype.toArray=function(){return __spread(this)},t.prototype.isEmpty=function(){return null===this._head},t.prototype.iterator=function(){var t;return __generator(this,function(e){switch(e.label){case 0:t=this._head,e.label=1;case 1:return t?[4,t.value]:[3,3];case 2:return e.sent(),t=t.next,[3,1];case 3:return[2]}})},t.prototype[Symbol.iterator]=function(){return this.iterator()},t}(),SinglyList=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.apply(this,__spread(e))||this}return __extends(e,t),e.prototype.append=function(t){var e=new SinglyNode(t);return this._tail?(this._tail.next=e,this._tail=e):this._head=this._tail=e,this._length++,!0},e.prototype.prepend=function(t){var e=new SinglyNode(t);return this._head?(e.next=this._head,this._head=e):this._head=this._tail=e,this._length++,!0},e.prototype.remove=function(t){var e=this._head;if(e){if(e.value===t)return e.next?(this._head=e.next,e.next=null):this._head=this._tail=null,this._length--,t;for(var r=e;;){if(e.value===t)return e.next?r.next=e.next:(this._tail=r,this._tail.next=null),e.next=null,this._length--,t;if(!e.next)return;r=e,e=e.next}}},e.prototype.removeHead=function(){var t=this._head;if(t)return this._head.next?(this._head=t.next,t.next=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.removeTail=function(){var t=this._tail;if(t){if(this._head.next){for(var e=this._head;e.next!==t;)e=e.next;e.next=null,this._tail=e}else this._head=null,this._tail=null;return this._length--,t.value}},e.prototype.reverse=function(){if(this._head){var t,e=this._head,r=null;for(this._tail=this._head;null!==e;)t=e.next,e.next=r,r=e,e=t;this._head=r}},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(List),AbstractCircleSinglyList=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=t.apply(this,__spread(e))||this;return n.cyclization(),n}return __extends(e,t),e.prototype.iterator=function(){var t;return __generator(this,function(e){switch(e.label){case 0:t=this._head,e.label=1;case 1:return t?[4,t.value]:[3,3];case 2:return e.sent(),(t=t.next)===this._head&&(t=null),[3,1];case 3:return[2]}})},e.prototype.circleIterator=function(){var t;return __generator(this,function(e){switch(e.label){case 0:t=this._head,e.label=1;case 1:return t?[4,t.value]:[3,3];case 2:return e.sent(),t=t.next,[3,1];case 3:return[2]}})},e.prototype[Symbol.iterator]=function(){return this.iterator()},e.prototype.mapToNormalListFn=function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.breakCircle();var i=t.prototype[e].apply(this,r);return this.cyclization(),i},e.prototype.getNode=function(t){return this.mapToNormalListFn("getNode",t)},e.prototype.append=function(t){return this.mapToNormalListFn("append",t)},e.prototype.prepend=function(t){return this.mapToNormalListFn("prepend",t)},e.prototype.indexOf=function(t){return this.mapToNormalListFn("indexOf",t)},e.prototype.remove=function(t){return this.mapToNormalListFn("remove",t)},e.prototype.removeHead=function(){return this.mapToNormalListFn("removeHead")},e.prototype.removeTail=function(){return this.mapToNormalListFn("removeTail")},e.prototype.first=function(t){invariant(t>=0,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.circleIterator(),r=[],n=0;n<t;n++){var i=e.next();r.push(i.value)}return r},e.prototype.toArray=function(){return this.mapToNormalListFn("toArray")},e.prototype.reverse=function(){return this.mapToNormalListFn("reverse")},e}(SinglyList),CircleSinglyList=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=t.apply(this,__spread(e))||this;return n.cyclization(),n}return __extends(e,t),e.prototype.breakCircle=function(){this._tail&&this._tail.next===this._head&&(this._tail.next=null)},e.prototype.cyclization=function(){this._tail&&null===this._tail.next&&(this._tail.next=this._head)},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(AbstractCircleSinglyList),DoublyList=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.apply(this,__spread(e))||this}return __extends(e,t),e.prototype.append=function(t){var e=new DoublyNode(t);return this._tail?(this._tail.next=e,e.prev=this._tail,this._tail=e):this._head=this._tail=e,this._length++,!0},e.prototype.prepend=function(t){var e=new DoublyNode(t);return this._head?(e.next=this._head,this._head.prev=e,this._head=e):this._head=this._tail=e,this._length++,!0},e.prototype.remove=function(t){var e=this._head;if(e){if(e.value===t)return e.next?(this._head=e.next,this._head.prev=null,e.next=e.prev=null):this._head=this._tail=null,this._length--,t;for(;;){if(e.value===t)return e.next?(e.prev.next=e.next,e.next.prev=e.prev,e.next=e.prev=null):(e.prev.next=null,this._tail=e.prev,e.next=e.prev=null),this._length--,e.value;if(!e.next)return;e=e.next}}},e.prototype.removeHead=function(){var t=this._head;if(t)return this._head.next?(t.next.prev=null,this._head=t.next,t.next=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.removeTail=function(){var t=this._tail;if(t)return this._head.next?(t.prev.next=null,this._tail=t.prev,t.next=t.prev=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.reverse=function(){if(this._head){var t,e=this._head,r=null;for(this._tail=this._head;null!==e;)t=e.next,e.next=r,e.prev=t,r=e,e=t;this._head=r}},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(List),AbstractCircleDoublyList=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=t.apply(this,__spread(e))||this;return n.cyclization(),n}return __extends(e,t),e.prototype.iterator=function(){var t;return __generator(this,function(e){switch(e.label){case 0:t=this._head,e.label=1;case 1:return t?[4,t.value]:[3,3];case 2:return e.sent(),(t=t.next)===this._head&&(t=null),[3,1];case 3:return[2]}})},e.prototype.circleIterator=function(){var t;return __generator(this,function(e){switch(e.label){case 0:t=this._head,e.label=1;case 1:return t?[4,t.value]:[3,3];case 2:return e.sent(),t=t.next,[3,1];case 3:return[2]}})},e.prototype[Symbol.iterator]=function(){return this.iterator()},e.prototype.mapToNormalListFn=function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.breakCircle();var i=t.prototype[e].apply(this,r);return this.cyclization(),i},e.prototype.getNode=function(t){return this.mapToNormalListFn("getNode",t)},e.prototype.append=function(t){return this.mapToNormalListFn("append",t)},e.prototype.prepend=function(t){return this.mapToNormalListFn("prepend",t)},e.prototype.indexOf=function(t){return this.mapToNormalListFn("indexOf",t)},e.prototype.remove=function(t){return this.mapToNormalListFn("remove",t)},e.prototype.removeHead=function(){return this.mapToNormalListFn("removeHead")},e.prototype.removeTail=function(){return this.mapToNormalListFn("removeTail")},e.prototype.first=function(t){invariant(t>=0,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.circleIterator(),r=[],n=0;n<t;n++){var i=e.next();r.push(i.value)}return r},e.prototype.toArray=function(){return this.mapToNormalListFn("toArray")},e.prototype.reverse=function(){return this.mapToNormalListFn("reverse")},e}(DoublyList),CircleDoublyList=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=t.apply(this,__spread(e))||this;return n.cyclization(),n}return __extends(e,t),e.prototype.breakCircle=function(){this._tail&&this._head&&this._tail.next===this._head&&(this._tail.next=null,this._head.prev=null)},e.prototype.cyclization=function(){this._head&&this._tail&&null===this._tail.next&&(this._tail.next=this._head,this._head.prev=this._tail)},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(AbstractCircleDoublyList);export{SinglyNode,DoublyNode,SinglyList,AbstractCircleSinglyList,CircleSinglyList,DoublyList,AbstractCircleDoublyList,CircleDoublyList};
var SinglyNode=function(){return function(t){this.value=t,this.next=null}}(),DoublyNode=function(){return function(t){this.value=t,this.next=null,this.prev=null}}(),extendStatics=function(t,e){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function __extends(t,e){function r(){this.constructor=t}extendStatics(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function __generator(t,e){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,l])}}}function __read(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function __spread(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(__read(arguments[e]));return t}var OBFUSCATED_ERROR="obfuse error occur";function invariant(t,e){if(!t)throw new Error("[linked-list] "+(e||OBFUSCATED_ERROR))}var CompareResult,INDEX_NOT_FOUND=-1;!function(t){t[t.EQUAL=0]="EQUAL",t[t.GREATER=1]="GREATER",t[t.LESS=-1]="LESS"}(CompareResult||(CompareResult={}));var Comparator=function(){function t(e){this.compare=e||t.defaultCompareFunction}return t.defaultCompareFunction=function(t,e){return t===e?CompareResult.EQUAL:t<e?CompareResult.LESS:CompareResult.GREATER},t.prototype.equal=function(t,e){return this.compare(t,e)===CompareResult.EQUAL},t.prototype.lessThan=function(t,e){return this.compare(t,e)===CompareResult.LESS},t.prototype.greaterThan=function(t,e){return this.compare(t,e)===CompareResult.GREATER},t.prototype.lessThanOrEqual=function(t,e){return this.lessThan(t,e)||this.equal(t,e)},t.prototype.greaterThanOrEqual=function(t,e){return this.greaterThan(t,e)||this.equal(t,e)},t.prototype.reverse=function(){var t=this.compare;this.compare=function(e,r){return t(r,e)}},t}(),List=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=this;this._head=null,this._tail=null,this._length=0,this.compare=new Comparator,t.length>0&&t.forEach(function(t){r.append(t)})}return Object.defineProperty(t.prototype,"head",{get:function(){return this._head?this._head.value:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"tail",{get:function(){return this._tail?this._tail.value:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this._length},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"loopLength",{get:function(){var t=!1,e=1;if(!this._head)return 0;for(var r=this._head,n=this._head;n.next&&n.next.next;)if(n=n.next.next,(r=r.next)===n){t=!0;break}if(t){for(n=n.next;r!==n;)e++,n=n.next;return e}return 0},enumerable:!0,configurable:!0}),t.prototype.getNode=function(t){var e=this._length;invariant(e>0&&t>=0&&t<e,"[linked-list] index "+t+" out of scope of list, which length is "+e);for(var r=this._head,n=0;n<t;)r=r.next,n++;return r},t.prototype.get=function(t){var e=this.getNode(t);return e?e.value:null},t.prototype.indexOf=function(t){if(!this._head)return INDEX_NOT_FOUND;for(var e=this._head,r=-1;e.next;){if(r++,this.compare.equal(e.value,t))return r;e=e.next}return e===this._tail&&this.compare.equal(e.value,t)&&(r+=1),r},t.prototype.first=function(t){invariant(t>=0,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.iterator(),r=[],n=Math.min(t,this.length),i=0;i<n;i++){var o=e.next();r.push(o.value)}return r},t.prototype.toArray=function(){return __spread(this)},t.prototype.isEmpty=function(){return null===this._head},t.prototype.iterator=function(){var t;return __generator(this,function(e){switch(e.label){case 0:t=this._head,e.label=1;case 1:return t?[4,t.value]:[3,3];case 2:return e.sent(),t=t.next,[3,1];case 3:return[2]}})},t.prototype[Symbol.iterator]=function(){return this.iterator()},t}(),SinglyList=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.apply(this,__spread(e))||this}return __extends(e,t),e.prototype.append=function(t){var e=new SinglyNode(t);return this._tail?(this._tail.next=e,this._tail=e):this._head=this._tail=e,this._length++,!0},e.prototype.prepend=function(t){var e=new SinglyNode(t);return this._head?(e.next=this._head,this._head=e):this._head=this._tail=e,this._length++,!0},e.prototype.remove=function(t){var e=this._head;if(e){if(this.compare.equal(e.value,t))return e.next?(this._head=e.next,e.next=null):this._head=this._tail=null,this._length--,t;for(var r=e;;){if(this.compare.equal(e.value,t))return e.next?r.next=e.next:(this._tail=r,this._tail.next=null),e.next=null,this._length--,t;if(!e.next)return;r=e,e=e.next}}},e.prototype.removeHead=function(){var t=this._head;if(t)return this._head.next?(this._head=t.next,t.next=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.removeTail=function(){var t=this._tail;if(t){if(this._head.next){for(var e=this._head;e.next!==t;)e=e.next;e.next=null,this._tail=e}else this._head=null,this._tail=null;return this._length--,t.value}},e.prototype.reverse=function(){if(this._head){var t,e=this._head,r=null;for(this._tail=this._head;null!==e;)t=e.next,e.next=r,r=e,e=t;this._head=r}},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(List),AbstractCircleSinglyList=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=t.apply(this,__spread(e))||this;return n.cyclization(),n}return __extends(e,t),e.prototype.iterator=function(){var t;return __generator(this,function(e){switch(e.label){case 0:t=this._head,e.label=1;case 1:return t?[4,t.value]:[3,3];case 2:return e.sent(),(t=t.next)===this._head&&(t=null),[3,1];case 3:return[2]}})},e.prototype.circleIterator=function(){var t;return __generator(this,function(e){switch(e.label){case 0:t=this._head,e.label=1;case 1:return t?[4,t.value]:[3,3];case 2:return e.sent(),t=t.next,[3,1];case 3:return[2]}})},e.prototype[Symbol.iterator]=function(){return this.iterator()},e.prototype.mapToNormalListFn=function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.breakCircle();var i=t.prototype[e].apply(this,r);return this.cyclization(),i},e.prototype.getNode=function(t){return this.mapToNormalListFn("getNode",t)},e.prototype.append=function(t){return this.mapToNormalListFn("append",t)},e.prototype.prepend=function(t){return this.mapToNormalListFn("prepend",t)},e.prototype.indexOf=function(t){return this.mapToNormalListFn("indexOf",t)},e.prototype.remove=function(t){return this.mapToNormalListFn("remove",t)},e.prototype.removeHead=function(){return this.mapToNormalListFn("removeHead")},e.prototype.removeTail=function(){return this.mapToNormalListFn("removeTail")},e.prototype.first=function(t){invariant(t>=0,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.circleIterator(),r=[],n=0;n<t;n++){var i=e.next();r.push(i.value)}return r},e.prototype.toArray=function(){return this.mapToNormalListFn("toArray")},e.prototype.reverse=function(){return this.mapToNormalListFn("reverse")},e}(SinglyList),CircleSinglyList=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=t.apply(this,__spread(e))||this;return n.cyclization(),n}return __extends(e,t),e.prototype.breakCircle=function(){this._tail&&this._tail.next===this._head&&(this._tail.next=null)},e.prototype.cyclization=function(){this._tail&&null===this._tail.next&&(this._tail.next=this._head)},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(AbstractCircleSinglyList),DoublyList=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.apply(this,__spread(e))||this}return __extends(e,t),e.prototype.append=function(t){var e=new DoublyNode(t);return this._tail?(this._tail.next=e,e.prev=this._tail,this._tail=e):this._head=this._tail=e,this._length++,!0},e.prototype.prepend=function(t){var e=new DoublyNode(t);return this._head?(e.next=this._head,this._head.prev=e,this._head=e):this._head=this._tail=e,this._length++,!0},e.prototype.remove=function(t){var e=this._head;if(e){if(this.compare.equal(e.value,t))return e.next?(this._head=e.next,this._head.prev=null,e.next=e.prev=null):this._head=this._tail=null,this._length--,t;for(;;){if(this.compare.equal(e.value,t))return e.next?(e.prev.next=e.next,e.next.prev=e.prev,e.next=e.prev=null):(e.prev.next=null,this._tail=e.prev,e.next=e.prev=null),this._length--,e.value;if(!e.next)return;e=e.next}}},e.prototype.removeHead=function(){var t=this._head;if(t)return this._head.next?(t.next.prev=null,this._head=t.next,t.next=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.removeTail=function(){var t=this._tail;if(t)return this._head.next?(t.prev.next=null,this._tail=t.prev,t.next=t.prev=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.reverse=function(){if(this._head){var t,e=this._head,r=null;for(this._tail=this._head;null!==e;)t=e.next,e.next=r,e.prev=t,r=e,e=t;this._head=r}},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(List),AbstractCircleDoublyList=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=t.apply(this,__spread(e))||this;return n.cyclization(),n}return __extends(e,t),e.prototype.iterator=function(){var t;return __generator(this,function(e){switch(e.label){case 0:t=this._head,e.label=1;case 1:return t?[4,t.value]:[3,3];case 2:return e.sent(),(t=t.next)===this._head&&(t=null),[3,1];case 3:return[2]}})},e.prototype.circleIterator=function(){var t;return __generator(this,function(e){switch(e.label){case 0:t=this._head,e.label=1;case 1:return t?[4,t.value]:[3,3];case 2:return e.sent(),t=t.next,[3,1];case 3:return[2]}})},e.prototype[Symbol.iterator]=function(){return this.iterator()},e.prototype.mapToNormalListFn=function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.breakCircle();var i=t.prototype[e].apply(this,r);return this.cyclization(),i},e.prototype.getNode=function(t){return this.mapToNormalListFn("getNode",t)},e.prototype.append=function(t){return this.mapToNormalListFn("append",t)},e.prototype.prepend=function(t){return this.mapToNormalListFn("prepend",t)},e.prototype.indexOf=function(t){return this.mapToNormalListFn("indexOf",t)},e.prototype.remove=function(t){return this.mapToNormalListFn("remove",t)},e.prototype.removeHead=function(){return this.mapToNormalListFn("removeHead")},e.prototype.removeTail=function(){return this.mapToNormalListFn("removeTail")},e.prototype.first=function(t){invariant(t>=0,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.circleIterator(),r=[],n=0;n<t;n++){var i=e.next();r.push(i.value)}return r},e.prototype.toArray=function(){return this.mapToNormalListFn("toArray")},e.prototype.reverse=function(){return this.mapToNormalListFn("reverse")},e}(DoublyList),CircleDoublyList=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=t.apply(this,__spread(e))||this;return n.cyclization(),n}return __extends(e,t),e.prototype.breakCircle=function(){this._tail&&this._head&&this._tail.next===this._head&&(this._tail.next=null,this._head.prev=null)},e.prototype.cyclization=function(){this._head&&this._tail&&null===this._tail.next&&(this._tail.next=this._head,this._head.prev=this._tail)},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,__spread([void 0],t)))},e}(AbstractCircleDoublyList);export{SinglyNode,DoublyNode,SinglyList,AbstractCircleSinglyList,CircleSinglyList,DoublyList,AbstractCircleDoublyList,CircleDoublyList};

@@ -110,2 +110,107 @@ (function (global, factory) {

/**
* enumeration of compare result, there is only three state
*
* @export
* @enum {number}
*/
var CompareResult;
(function (CompareResult) {
CompareResult[CompareResult["EQUAL"] = 0] = "EQUAL";
CompareResult[CompareResult["GREATER"] = 1] = "GREATER";
CompareResult[CompareResult["LESS"] = -1] = "LESS";
})(CompareResult || (CompareResult = {}));
/**
* a class that describe how compares two object
*
* @export
* @class Comparator
*/
var Comparator = /** @class */ (function () {
/**
* Creates an instance of Comparator.
* @param {compareFunction} compareFunction - function that implement compare operation
* @memberof Comparator
*/
function Comparator(compareFunction) {
this.compare = compareFunction || Comparator.defaultCompareFunction;
}
/**
* @param {(string|number)} a - compare target a
* @param {(string|number)} b - compare target b
* @returns {number}
*/
Comparator.defaultCompareFunction = function (a, b) {
if (a === b) {
return CompareResult.EQUAL;
}
return a < b ? CompareResult.LESS : CompareResult.GREATER;
};
/**
* compare if equal or not, a === b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.equal = function (a, b) {
return this.compare(a, b) === CompareResult.EQUAL;
};
/**
* compare if smaller. a < b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.lessThan = function (a, b) {
return this.compare(a, b) === CompareResult.LESS;
};
/**
* compare if greater. a > b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.greaterThan = function (a, b) {
return this.compare(a, b) === CompareResult.GREATER;
};
/**
* compare if smaller or equal. a <= b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.lessThanOrEqual = function (a, b) {
return this.lessThan(a, b) || this.equal(a, b);
};
/**
* compare if greater or equal. a >= b
*
* @param {*} a
* @param {*} b
* @returns {boolean}
* @memberof Comparator
*/
Comparator.prototype.greaterThanOrEqual = function (a, b) {
return this.greaterThan(a, b) || this.equal(a, b);
};
/**
* reverse the compare function
*
* @memberof Comparator
*/
Comparator.prototype.reverse = function () {
var compareOriginal = this.compare;
this.compare = function (a, b) { return compareOriginal(b, a); };
};
return Comparator;
}());
var List = /** @class */ (function () {

@@ -121,2 +226,3 @@ function List() {

this._length = 0;
this.compare = new Comparator();
if (values.length > 0) {

@@ -207,3 +313,3 @@ values.forEach(function (value) {

count++;
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
return count;

@@ -214,3 +320,3 @@ }

// 如果是末尾节点,需要额外处理
if (currentNode === this._tail && currentNode.value === val) {
if (currentNode === this._tail && this.compare.equal(currentNode.value, val)) {
count += 1;

@@ -302,3 +408,3 @@ }

}
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
// 这里需要注意,有两种情况:

@@ -320,3 +426,3 @@ if (currentNode.next) {

while (true) {
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
if (currentNode.next) {

@@ -588,3 +694,3 @@ prevNode.next = currentNode.next;

// 当首个元素恰好是目标值的时候
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
// 这里需要注意,有两种情况:

@@ -606,3 +712,3 @@ if (currentNode.next) {

while (true) {
if (currentNode.value === val) {
if (this.compare.equal(currentNode.value, val)) {
if (currentNode.next) {

@@ -609,0 +715,0 @@ // special case for last element

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Index={})}(this,function(t){"use strict";var r=function(t){this.value=t,this.next=null},i=function(t){this.value=t,this.next=null,this.prev=null},o=function(t,e){return(o=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])})(t,e)};function a(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function n(n,r){var i,o,a,t,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;l;)try{if(i=1,o&&(a=2&e[0]?o.return:e[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,e[1])).done)return a;switch(o=0,a&&(e=[2&e[0],a.value]),e[0]){case 0:case 1:a=e;break;case 4:return l.label++,{value:e[1],done:!1};case 5:l.label++,o=e[1],e=[0];continue;case 7:e=l.ops.pop(),l.trys.pop();continue;default:if(!(a=0<(a=l.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){l=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){l.label=e[1];break}if(6===e[0]&&l.label<a[1]){l.label=a[1],a=e;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(e);break}a[2]&&l.ops.pop(),l.trys.pop();continue}e=r.call(n,l)}catch(t){e=[6,t],o=0}finally{i=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function l(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||0<e--)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function u(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(l(arguments[e]));return t}function h(t,e){if(!t)throw new Error("[linked-list] "+(e||"obfuse error occur"))}var e=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this;this._head=null,this._tail=null,(this._length=0)<t.length&&t.forEach(function(t){n.append(t)})}return Object.defineProperty(t.prototype,"head",{get:function(){return this._head?this._head.value:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"tail",{get:function(){return this._tail?this._tail.value:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this._length},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"loopLength",{get:function(){var t=!1,e=1;if(!this._head)return 0;for(var n=this._head,r=this._head;r.next&&r.next.next;)if(r=r.next.next,(n=n.next)===r){t=!0;break}if(t){for(r=r.next;n!==r;)e++,r=r.next;return e}return 0},enumerable:!0,configurable:!0}),t.prototype.getNode=function(t){var e=this._length;h(0<e&&0<=t&&t<e,"[linked-list] index "+t+" out of scope of list, which length is "+e);for(var n=this._head,r=0;r<t;)n=n.next,r++;return n},t.prototype.get=function(t){var e=this.getNode(t);return e?e.value:null},t.prototype.indexOf=function(t){if(!this._head)return-1;for(var e=this._head,n=-1;e.next;){if(n++,e.value===t)return n;e=e.next}return e===this._tail&&e.value===t&&(n+=1),n},t.prototype.first=function(t){h(0<=t,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.iterator(),n=[],r=Math.min(t,this.length),i=0;i<r;i++){var o=e.next();n.push(o.value)}return n},t.prototype.toArray=function(){return u(this)},t.prototype.isEmpty=function(){return null===this._head},t.prototype.iterator=function(){var e;return n(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})},t.prototype[Symbol.iterator]=function(){return this.iterator()},t}(),s=function(n){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.apply(this,u(t))||this}return a(e,n),e.prototype.append=function(t){var e=new r(t);return this._tail?(this._tail.next=e,this._tail=e):this._head=this._tail=e,this._length++,!0},e.prototype.prepend=function(t){var e=new r(t);return this._head?(e.next=this._head,this._head=e):this._head=this._tail=e,this._length++,!0},e.prototype.remove=function(t){var e=this._head;if(e){if(e.value===t)return e.next?(this._head=e.next,e.next=null):this._head=this._tail=null,this._length--,t;for(var n=e;;){if(e.value===t)return e.next?n.next=e.next:(this._tail=n,this._tail.next=null),e.next=null,this._length--,t;if(!e.next)return;e=(n=e).next}}},e.prototype.removeHead=function(){var t=this._head;if(t)return this._head.next?(this._head=t.next,t.next=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.removeTail=function(){var t=this._tail;if(t){if(this._head.next){for(var e=this._head;e.next!==t;)e=e.next;e.next=null,this._tail=e}else this._head=null,this._tail=null;return this._length--,t.value}},e.prototype.reverse=function(){if(this._head){var t,e=this._head,n=null;for(this._tail=this._head;null!==e;)t=e.next,e.next=n,n=e,e=t;this._head=n}},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,u([void 0],t)))},e}(e),p=function(i){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=i.apply(this,u(t))||this;return n.cyclization(),n}return a(t,i),t.prototype.iterator=function(){var e;return n(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),(e=e.next)===this._head&&(e=null),[3,1];case 3:return[2]}})},t.prototype.circleIterator=function(){var e;return n(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})},t.prototype[Symbol.iterator]=function(){return this.iterator()},t.prototype.mapToNormalListFn=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];this.breakCircle();var r=i.prototype[t].apply(this,e);return this.cyclization(),r},t.prototype.getNode=function(t){return this.mapToNormalListFn("getNode",t)},t.prototype.append=function(t){return this.mapToNormalListFn("append",t)},t.prototype.prepend=function(t){return this.mapToNormalListFn("prepend",t)},t.prototype.indexOf=function(t){return this.mapToNormalListFn("indexOf",t)},t.prototype.remove=function(t){return this.mapToNormalListFn("remove",t)},t.prototype.removeHead=function(){return this.mapToNormalListFn("removeHead")},t.prototype.removeTail=function(){return this.mapToNormalListFn("removeTail")},t.prototype.first=function(t){h(0<=t,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.circleIterator(),n=[],r=0;r<t;r++){var i=e.next();n.push(i.value)}return n},t.prototype.toArray=function(){return this.mapToNormalListFn("toArray")},t.prototype.reverse=function(){return this.mapToNormalListFn("reverse")},t}(s),c=function(r){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=r.apply(this,u(t))||this;return n.cyclization(),n}return a(e,r),e.prototype.breakCircle=function(){this._tail&&this._tail.next===this._head&&(this._tail.next=null)},e.prototype.cyclization=function(){this._tail&&null===this._tail.next&&(this._tail.next=this._head)},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,u([void 0],t)))},e}(p),f=function(n){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.apply(this,u(t))||this}return a(e,n),e.prototype.append=function(t){var e=new i(t);return this._tail?((this._tail.next=e).prev=this._tail,this._tail=e):this._head=this._tail=e,this._length++,!0},e.prototype.prepend=function(t){var e=new i(t);return this._head?(e.next=this._head,this._head.prev=e,this._head=e):this._head=this._tail=e,this._length++,!0},e.prototype.remove=function(t){var e=this._head;if(e){if(e.value===t)return e.next?(this._head=e.next,this._head.prev=null,e.next=e.prev=null):this._head=this._tail=null,this._length--,t;for(;;){if(e.value===t)return e.next?(e.prev.next=e.next,e.next.prev=e.prev):(e.prev.next=null,this._tail=e.prev),e.next=e.prev=null,this._length--,e.value;if(!e.next)return;e=e.next}}},e.prototype.removeHead=function(){var t=this._head;if(t)return this._head.next?(t.next.prev=null,this._head=t.next,t.next=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.removeTail=function(){var t=this._tail;if(t)return this._head.next?(t.prev.next=null,this._tail=t.prev,t.next=t.prev=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.reverse=function(){if(this._head){var t,e=this._head,n=null;for(this._tail=this._head;null!==e;)t=e.next,e.next=n,e.prev=t,n=e,e=t;this._head=n}},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,u([void 0],t)))},e}(e),d=function(i){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=i.apply(this,u(t))||this;return n.cyclization(),n}return a(t,i),t.prototype.iterator=function(){var e;return n(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),(e=e.next)===this._head&&(e=null),[3,1];case 3:return[2]}})},t.prototype.circleIterator=function(){var e;return n(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})},t.prototype[Symbol.iterator]=function(){return this.iterator()},t.prototype.mapToNormalListFn=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];this.breakCircle();var r=i.prototype[t].apply(this,e);return this.cyclization(),r},t.prototype.getNode=function(t){return this.mapToNormalListFn("getNode",t)},t.prototype.append=function(t){return this.mapToNormalListFn("append",t)},t.prototype.prepend=function(t){return this.mapToNormalListFn("prepend",t)},t.prototype.indexOf=function(t){return this.mapToNormalListFn("indexOf",t)},t.prototype.remove=function(t){return this.mapToNormalListFn("remove",t)},t.prototype.removeHead=function(){return this.mapToNormalListFn("removeHead")},t.prototype.removeTail=function(){return this.mapToNormalListFn("removeTail")},t.prototype.first=function(t){h(0<=t,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.circleIterator(),n=[],r=0;r<t;r++){var i=e.next();n.push(i.value)}return n},t.prototype.toArray=function(){return this.mapToNormalListFn("toArray")},t.prototype.reverse=function(){return this.mapToNormalListFn("reverse")},t}(f),v=function(r){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=r.apply(this,u(t))||this;return n.cyclization(),n}return a(e,r),e.prototype.breakCircle=function(){this._tail&&this._head&&this._tail.next===this._head&&(this._tail.next=null,this._head.prev=null)},e.prototype.cyclization=function(){this._head&&this._tail&&null===this._tail.next&&(this._tail.next=this._head,this._head.prev=this._tail)},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,u([void 0],t)))},e}(d);t.SinglyNode=r,t.DoublyNode=i,t.SinglyList=s,t.AbstractCircleSinglyList=p,t.CircleSinglyList=c,t.DoublyList=f,t.AbstractCircleDoublyList=d,t.CircleDoublyList=v,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Index={})}(this,function(t){"use strict";var r=function(t){this.value=t,this.next=null},i=function(t){this.value=t,this.next=null,this.prev=null},o=function(t,e){return(o=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])})(t,e)};function a(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function n(n,r){var i,o,a,t,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;l;)try{if(i=1,o&&(a=2&e[0]?o.return:e[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,e[1])).done)return a;switch(o=0,a&&(e=[2&e[0],a.value]),e[0]){case 0:case 1:a=e;break;case 4:return l.label++,{value:e[1],done:!1};case 5:l.label++,o=e[1],e=[0];continue;case 7:e=l.ops.pop(),l.trys.pop();continue;default:if(!(a=0<(a=l.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){l=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){l.label=e[1];break}if(6===e[0]&&l.label<a[1]){l.label=a[1],a=e;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(e);break}a[2]&&l.ops.pop(),l.trys.pop();continue}e=r.call(n,l)}catch(t){e=[6,t],o=0}finally{i=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function l(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||0<e--)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function u(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(l(arguments[e]));return t}function h(t,e){if(!t)throw new Error("[linked-list] "+(e||"obfuse error occur"))}var s,e;(e=s||(s={}))[e.EQUAL=0]="EQUAL",e[e.GREATER=1]="GREATER",e[e.LESS=-1]="LESS";var p=function(){function e(t){this.compare=t||e.defaultCompareFunction}return e.defaultCompareFunction=function(t,e){return t===e?s.EQUAL:t<e?s.LESS:s.GREATER},e.prototype.equal=function(t,e){return this.compare(t,e)===s.EQUAL},e.prototype.lessThan=function(t,e){return this.compare(t,e)===s.LESS},e.prototype.greaterThan=function(t,e){return this.compare(t,e)===s.GREATER},e.prototype.lessThanOrEqual=function(t,e){return this.lessThan(t,e)||this.equal(t,e)},e.prototype.greaterThanOrEqual=function(t,e){return this.greaterThan(t,e)||this.equal(t,e)},e.prototype.reverse=function(){var n=this.compare;this.compare=function(t,e){return n(e,t)}},e}(),c=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this;this._head=null,this._tail=null,this._length=0,this.compare=new p,0<t.length&&t.forEach(function(t){n.append(t)})}return Object.defineProperty(t.prototype,"head",{get:function(){return this._head?this._head.value:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"tail",{get:function(){return this._tail?this._tail.value:void 0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this._length},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"loopLength",{get:function(){var t=!1,e=1;if(!this._head)return 0;for(var n=this._head,r=this._head;r.next&&r.next.next;)if(r=r.next.next,(n=n.next)===r){t=!0;break}if(t){for(r=r.next;n!==r;)e++,r=r.next;return e}return 0},enumerable:!0,configurable:!0}),t.prototype.getNode=function(t){var e=this._length;h(0<e&&0<=t&&t<e,"[linked-list] index "+t+" out of scope of list, which length is "+e);for(var n=this._head,r=0;r<t;)n=n.next,r++;return n},t.prototype.get=function(t){var e=this.getNode(t);return e?e.value:null},t.prototype.indexOf=function(t){if(!this._head)return-1;for(var e=this._head,n=-1;e.next;){if(n++,this.compare.equal(e.value,t))return n;e=e.next}return e===this._tail&&this.compare.equal(e.value,t)&&(n+=1),n},t.prototype.first=function(t){h(0<=t,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.iterator(),n=[],r=Math.min(t,this.length),i=0;i<r;i++){var o=e.next();n.push(o.value)}return n},t.prototype.toArray=function(){return u(this)},t.prototype.isEmpty=function(){return null===this._head},t.prototype.iterator=function(){var e;return n(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})},t.prototype[Symbol.iterator]=function(){return this.iterator()},t}(),f=function(n){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.apply(this,u(t))||this}return a(e,n),e.prototype.append=function(t){var e=new r(t);return this._tail?(this._tail.next=e,this._tail=e):this._head=this._tail=e,this._length++,!0},e.prototype.prepend=function(t){var e=new r(t);return this._head?(e.next=this._head,this._head=e):this._head=this._tail=e,this._length++,!0},e.prototype.remove=function(t){var e=this._head;if(e){if(this.compare.equal(e.value,t))return e.next?(this._head=e.next,e.next=null):this._head=this._tail=null,this._length--,t;for(var n=e;;){if(this.compare.equal(e.value,t))return e.next?n.next=e.next:(this._tail=n,this._tail.next=null),e.next=null,this._length--,t;if(!e.next)return;e=(n=e).next}}},e.prototype.removeHead=function(){var t=this._head;if(t)return this._head.next?(this._head=t.next,t.next=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.removeTail=function(){var t=this._tail;if(t){if(this._head.next){for(var e=this._head;e.next!==t;)e=e.next;e.next=null,this._tail=e}else this._head=null,this._tail=null;return this._length--,t.value}},e.prototype.reverse=function(){if(this._head){var t,e=this._head,n=null;for(this._tail=this._head;null!==e;)t=e.next,e.next=n,n=e,e=t;this._head=n}},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,u([void 0],t)))},e}(c),d=function(i){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=i.apply(this,u(t))||this;return n.cyclization(),n}return a(t,i),t.prototype.iterator=function(){var e;return n(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),(e=e.next)===this._head&&(e=null),[3,1];case 3:return[2]}})},t.prototype.circleIterator=function(){var e;return n(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})},t.prototype[Symbol.iterator]=function(){return this.iterator()},t.prototype.mapToNormalListFn=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];this.breakCircle();var r=i.prototype[t].apply(this,e);return this.cyclization(),r},t.prototype.getNode=function(t){return this.mapToNormalListFn("getNode",t)},t.prototype.append=function(t){return this.mapToNormalListFn("append",t)},t.prototype.prepend=function(t){return this.mapToNormalListFn("prepend",t)},t.prototype.indexOf=function(t){return this.mapToNormalListFn("indexOf",t)},t.prototype.remove=function(t){return this.mapToNormalListFn("remove",t)},t.prototype.removeHead=function(){return this.mapToNormalListFn("removeHead")},t.prototype.removeTail=function(){return this.mapToNormalListFn("removeTail")},t.prototype.first=function(t){h(0<=t,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.circleIterator(),n=[],r=0;r<t;r++){var i=e.next();n.push(i.value)}return n},t.prototype.toArray=function(){return this.mapToNormalListFn("toArray")},t.prototype.reverse=function(){return this.mapToNormalListFn("reverse")},t}(f),y=function(r){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=r.apply(this,u(t))||this;return n.cyclization(),n}return a(e,r),e.prototype.breakCircle=function(){this._tail&&this._tail.next===this._head&&(this._tail.next=null)},e.prototype.cyclization=function(){this._tail&&null===this._tail.next&&(this._tail.next=this._head)},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,u([void 0],t)))},e}(d),v=function(n){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.apply(this,u(t))||this}return a(e,n),e.prototype.append=function(t){var e=new i(t);return this._tail?((this._tail.next=e).prev=this._tail,this._tail=e):this._head=this._tail=e,this._length++,!0},e.prototype.prepend=function(t){var e=new i(t);return this._head?(e.next=this._head,this._head.prev=e,this._head=e):this._head=this._tail=e,this._length++,!0},e.prototype.remove=function(t){var e=this._head;if(e){if(this.compare.equal(e.value,t))return e.next?(this._head=e.next,this._head.prev=null,e.next=e.prev=null):this._head=this._tail=null,this._length--,t;for(;;){if(this.compare.equal(e.value,t))return e.next?(e.prev.next=e.next,e.next.prev=e.prev):(e.prev.next=null,this._tail=e.prev),e.next=e.prev=null,this._length--,e.value;if(!e.next)return;e=e.next}}},e.prototype.removeHead=function(){var t=this._head;if(t)return this._head.next?(t.next.prev=null,this._head=t.next,t.next=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.removeTail=function(){var t=this._tail;if(t)return this._head.next?(t.prev.next=null,this._tail=t.prev,t.next=t.prev=null):(this._head=null,this._tail=null),this._length--,t.value},e.prototype.reverse=function(){if(this._head){var t,e=this._head,n=null;for(this._tail=this._head;null!==e;)t=e.next,e.next=n,e.prev=t,n=e,e=t;this._head=n}},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,u([void 0],t)))},e}(c),_=function(i){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=i.apply(this,u(t))||this;return n.cyclization(),n}return a(t,i),t.prototype.iterator=function(){var e;return n(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),(e=e.next)===this._head&&(e=null),[3,1];case 3:return[2]}})},t.prototype.circleIterator=function(){var e;return n(this,function(t){switch(t.label){case 0:e=this._head,t.label=1;case 1:return e?[4,e.value]:[3,3];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}})},t.prototype[Symbol.iterator]=function(){return this.iterator()},t.prototype.mapToNormalListFn=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];this.breakCircle();var r=i.prototype[t].apply(this,e);return this.cyclization(),r},t.prototype.getNode=function(t){return this.mapToNormalListFn("getNode",t)},t.prototype.append=function(t){return this.mapToNormalListFn("append",t)},t.prototype.prepend=function(t){return this.mapToNormalListFn("prepend",t)},t.prototype.indexOf=function(t){return this.mapToNormalListFn("indexOf",t)},t.prototype.remove=function(t){return this.mapToNormalListFn("remove",t)},t.prototype.removeHead=function(){return this.mapToNormalListFn("removeHead")},t.prototype.removeTail=function(){return this.mapToNormalListFn("removeTail")},t.prototype.first=function(t){h(0<=t,"[linked-list] param 'num' ("+t+") should not less than 0");for(var e=this.circleIterator(),n=[],r=0;r<t;r++){var i=e.next();n.push(i.value)}return n},t.prototype.toArray=function(){return this.mapToNormalListFn("toArray")},t.prototype.reverse=function(){return this.mapToNormalListFn("reverse")},t}(v),m=function(r){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=r.apply(this,u(t))||this;return n.cyclization(),n}return a(e,r),e.prototype.breakCircle=function(){this._tail&&this._head&&this._tail.next===this._head&&(this._tail.next=null,this._head.prev=null)},e.prototype.cyclization=function(){this._head&&this._tail&&null===this._tail.next&&(this._tail.next=this._head,this._head.prev=this._tail)},e.prototype.clone=function(){var t=this.toArray();return new(e.bind.apply(e,u([void 0],t)))},e}(_);t.SinglyNode=r,t.DoublyNode=i,t.SinglyList=f,t.AbstractCircleSinglyList=d,t.CircleSinglyList=y,t.DoublyList=v,t.AbstractCircleDoublyList=_,t.CircleDoublyList=m,Object.defineProperty(t,"__esModule",{value:!0})});
import { ListNode } from './node';
import Comparator from 'ss-comparator';
export default abstract class List<T, U extends ListNode<T>> {

@@ -6,2 +7,3 @@ protected _head: U | null;

protected _length: number;
compare: Comparator;
constructor(...values: T[]);

@@ -8,0 +10,0 @@ readonly head: T | void;

{
"name": "ss-linked-list",
"version": "1.1.2",
"version": "1.1.3",
"main": "dist/index.cjs.js",

@@ -34,3 +34,5 @@ "module": "dist/index.esm.js",

},
"dependencies": {},
"dependencies": {
"ss-comparator": "^1.0.0"
},
"devDependencies": {

@@ -37,0 +39,0 @@ "@types/jest": "^23.3.1",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc