@data-structure-algebra/doubly-linked-list
Version:
Doubly linked list for JavaScript
3 lines (2 loc) • 11.4 kB
JavaScript
function t(t,n,r){this.value=t,this.prev=n,this.next=r}function n(t,n){t.next=n,n.prev=t}function r(t,r){n(t.prev,r)}function e(){e=function(){return t};var t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,n,r){t[n]=r.value},i="function"==typeof Symbol?Symbol:{},u=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function l(t,n,r){return Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[n]}try{l({},"")}catch(t){l=function(t,n,r){return t[n]=r}}function f(t,n,r,e){var i=Object.create((n&&n.prototype instanceof p?n:p).prototype),u=new O(e||[]);return o(i,"_invoke",{value:L(t,r,u)}),i}function s(t,n,r){try{return{type:"normal",arg:t.call(n,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var h={};function p(){}function v(){}function y(){}var d={};l(d,u,function(){return this});var g=Object.getPrototypeOf,w=g&&g(g(_([])));w&&w!==n&&r.call(w,u)&&(d=w);var m=y.prototype=p.prototype=Object.create(d);function x(t){["next","throw","return"].forEach(function(n){l(t,n,function(t){return this._invoke(n,t)})})}function b(t,n){function e(o,i,u,a){var c=s(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?n.resolve(f.__await).then(function(t){e("next",t,u,a)},function(t){e("throw",t,u,a)}):n.resolve(f).then(function(t){l.value=t,u(l)},function(t){return e("throw",t,u,a)})}a(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new n(function(n,o){e(t,r,n,o)})}return i=i?i.then(o,o):o()}})}function L(t,n,r){var e="suspendedStart";return function(o,i){if("executing"===e)throw new Error("Generator is already running");if("completed"===e){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var u=r.delegate;if(u){var a=E(u,r);if(a){if(a===h)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===e)throw e="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);e="executing";var c=s(t,n,r);if("normal"===c.type){if(e=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(e="completed",r.method="throw",r.arg=c.arg)}}}function E(t,n){var r=t.iterator[n.method];if(void 0===r){if(n.delegate=null,"throw"===n.method){if(t.iterator.return&&(n.method="return",n.arg=void 0,E(t,n),"throw"===n.method))return h;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var e=s(r,t.iterator,n.arg);if("throw"===e.type)return n.method="throw",n.arg=e.arg,n.delegate=null,h;var o=e.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=void 0),n.delegate=null,h):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,h)}function k(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function j(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function _(t){if(t){var n=t[u];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,o=function n(){for(;++e<t.length;)if(r.call(t,e))return n.value=t[e],n.done=!1,n;return n.value=void 0,n.done=!0,n};return o.next=o}}return{next:S}}function S(){return{value:void 0,done:!0}}return v.prototype=y,o(m,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:v,configurable:!0}),v.displayName=l(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===v||"GeneratorFunction"===(n.displayName||n.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,l(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},x(b.prototype),l(b.prototype,a,function(){return this}),t.AsyncIterator=b,t.async=function(n,r,e,o,i){void 0===i&&(i=Promise);var u=new b(f(n,r,e,o),i);return t.isGeneratorFunction(r)?u:u.next().then(function(t){return t.done?t.value:u.next()})},x(m),l(m,c,"Generator"),l(m,u,function(){return this}),l(m,"toString",function(){return"[object Generator]"}),t.keys=function(t){var n=Object(t),r=[];for(var e in n)r.push(e);return r.reverse(),function t(){for(;r.length;){var e=r.pop();if(e in n)return t.value=e,t.done=!1,t}return t.done=!0,t}},t.values=_,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function e(r,e){return u.type="throw",u.arg=t,n.next=r,e&&(n.method="next",n.arg=void 0),!!e}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return e(i.catchLoc,!0);if(this.prev<i.finallyLoc)return e(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return e(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return e(i.finallyLoc)}}}},abrupt:function(t,n){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=n&&n<=i.finallyLoc&&(i=null);var u=i?i.completion:{};return u.type=t,u.arg=n,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(u)},complete:function(t,n){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&n&&(this.next=n),h},finish:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),h}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc===t){var e=r.completion;if("throw"===e.type){var o=e.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:_(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function o(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,e=new Array(n);r<n;r++)e[r]=t[r];return e}function i(t,n){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,n){if(t){if("string"==typeof t)return o(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){r&&(t=r);var e=0,i=function(){};return{s:i,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,u=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw u}}}}function u(n,r){const e=new t(r,n,null);return n.next=e,e}function a(t,n){let r=t;var e,o=i(n);try{for(o.s();!(e=o.n()).done;)r=u(r,e.value)}catch(t){o.e(t)}finally{o.f()}return r}function c(n,r,e){const o=new t(e,n,r);return n.next=o,r.prev=o,o}function l(t,n){return c(t,t.next,n)}function f(t,n){return c(t.prev,t,n)}var s=/*#__PURE__*/e().mark(h);function h(t){var n,r;return e().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=t;case 1:return n=(r=n).next,e.next=5,r;case 5:if(null!==n){e.next=1;break}case 6:case"end":return e.stop()}},s)}var p=/*#__PURE__*/e().mark(v);function v(t){var n;return e().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:n=t;case 1:return r.next=3,n;case 3:n=n.next;case 4:if(null!==n){r.next=1;break}case 5:case"end":return r.stop()}},p)}function y(t){let n=t;for(;null!==n.next;)n=n.next;return n}function d(t){let n=1,r=t.next;for(;null!==r;)++n,r=r.next;return n}function g(t){const n=t.prev;return n.next=null,n}function w(t){r(t,t.next)}function m(t){t.prev.next=null,t.prev=null}function x(t,r,e){m(r),n(e,t)}function b(t,n,r){let e=n;for(;--r;)e=e.prev;const o=e.prev;return x(t,e,n),[e,o]}function L(t,n,r,e){const o=e%r;return 0===o?[t,n]:b(t,n,o)}function E(t,n,r){let e=n,o=r;for(;--o;){if(e===t)return L(t,n,r-o,r);e=e.prev}const i=e.prev;return x(t,e,n),[e,i]}function k(t,n,r){let e=t;do{e=e.next}while(--r);const o=e.prev;return x(t,e,n),[e,o]}function j(t,n,r,e){const o=e%r;return 0===o?[t,n]:k(t,n,o)}function O(t,n,r){let e=t,o=r;do{if(e===n)return j(t,n,r-o+1,r);e=e.next}while(--o);const i=e.prev;return x(t,e,n),[e,i]}function _(t){const n=t.next;return n.prev=null,n}function S(n,r){const e=new t(r,null,n);return n.prev=e,e}function A(t,r,e){return null===t?e:(null===e||n(r,e),t)}function G(){return null}function N(n){const r=n[Symbol.iterator](),e=r.next();if(e.done)return null;const o=new t(e.value,null,null);return a(o,r),o}var P=/*#__PURE__*/e().mark(I);function I(t){return e().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(null===t){n.next=2;break}return n.delegateYield(h(t),"t0",2);case 2:case"end":return n.stop()}},P)}function T(t){return null===t?null:y(t)}var F=t=>null===t?0:d(t);function Y(t){if(null===t)throw new Error("input list is empty");return[null===t.prev?null:g(t),t]}function C(n,r,e){return null===n?new t(e,null,null):(u(r,e),n)}function M(t,n,r){return t===n||0===r?[t,n]:r>0?O(t,n,r):E(t,n,-r)}var U=(t,n,r)=>M(t,n,-r);function $(t){if(null===t)throw new Error("input list is empty");return[null===t.next?null:_(t),t]}function q(t,n){return t===n?[null,t]:null===n?[t,null]:(m(n),[t,n])}function z(n,r){return null===n?new t(r,null,null):S(n,r)}var B=/*#__PURE__*/e().mark(D);function D(t){var n,r,o;return e().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null===t){e.next=18;break}n=i(v(t)),e.prev=2,n.s();case 4:if((r=n.n()).done){e.next=10;break}return o=r.value,e.next=8,o.value;case 8:e.next=4;break;case 10:e.next=15;break;case 12:e.prev=12,e.t0=e.catch(2),n.e(e.t0);case 15:return e.prev=15,n.f(),e.finish(15);case 18:case"end":return e.stop()}},B,null,[[2,12,15,18]])}export{t as Node,n as _concat,r as _erase,a as _extend,l as _insertAfter,f as _insertBefore,c as _insertBetween,h as _iter,v as _iter_fast,y as _last,d as _len,g as _pop,u as _push,w as _remove,b as _rotate_left,L as _rotate_left_modulo,E as _rotate_left_unknown_length,k as _rotate_right,j as _rotate_right_modulo,O as _rotate_right_unknown_length,x as _rotate_to,_ as _shift,m as _split,S as _unshift,A as concat,G as empty,N as from,I as iter,T as last,F as len,Y as pop,C as push,U as rotate_left,M as rotate_right,$ as shift,q as split,z as unshift,D as values};
//# sourceMappingURL=index.module.js.map