UNPKG

@data-structure/deque

Version:
1 lines 23.5 kB
{"version":3,"file":"index.cjs","sources":["../src/implementation/Deque.js","../src/implementation/ArbitrarySizeDeque.js","../src/implementation/BoundedDeque.js","../src/implementation/EmptyDeque.js","../src/implementation/SingleElementDeque.js","../src/implementation/UnboundedDeque.js","../src/_deque.js","../src/deque.js"],"sourcesContent":["import {\n\tNotImplementedError,\n\tIndexError,\n\tValueError,\n} from '@failure-abstraction/error';\n\n/**\n * Deque.\n */\nexport default function Deque() {}\n\n/**\n * Deque.prototype.len.\n *\n * @return {Number}\n */\nDeque.prototype.len = function () {\n\tthrow new NotImplementedError('len');\n};\n\n/**\n * Deque.prototype.capacity.\n *\n * @return {Number}\n */\nDeque.prototype.capacity = function () {\n\tthrow new NotImplementedError('capacity');\n};\n\n/**\n * Deque.prototype.empty.\n *\n * @return {Boolean}\n */\nDeque.prototype.empty = function () {\n\treturn this.len() === 0;\n};\n\n/**\n * Deque.prototype[Symbol.iterator].\n *\n * @return {Iterable<any>}\n */\nDeque.prototype[Symbol.iterator] = function () {\n\treturn this.values();\n};\n\n/**\n * Deque.prototype.values.\n *\n * @return {Iterable<any>}\n */\nDeque.prototype.values = function () {\n\tthrow new NotImplementedError('values');\n};\n\n/**\n * Deque.prototype.append.\n *\n * @param {any} _x\n */\nDeque.prototype.append = function (_x) {\n\tthrow new NotImplementedError('append');\n};\n\n/**\n * Deque.prototype.appendleft.\n *\n * @param {any} _x\n */\nDeque.prototype.appendleft = function (_x) {\n\tthrow new NotImplementedError('appendleft');\n};\n\n/**\n * Deque.prototype.clear.\n *\n * @return {Deque}\n */\nDeque.prototype.clear = function () {\n\tthrow new NotImplementedError('clear');\n};\n\n/**\n * Deque.prototype.copy.\n *\n * @return {Deque}\n */\nDeque.prototype.copy = function () {\n\tthrow new NotImplementedError('copy');\n};\n\n/**\n * Deque.prototype.count.\n *\n * @param {any} x\n * @return {Number}\n */\nDeque.prototype.count = function (x) {\n\tlet c = 0;\n\n\tfor (const element of this) {\n\t\tif (element === x) {\n\t\t\t++c;\n\t\t}\n\t}\n\n\treturn c;\n};\n\n/**\n * Deque.prototype.extend.\n *\n * @param {Iterable<any>} iterable\n */\nDeque.prototype.extend = function (iterable) {\n\tfor (const x of iterable) {\n\t\tthis.append(x);\n\t}\n\n\treturn this;\n};\n\n/**\n * Deque.prototype.extendleft.\n *\n * @param {Iterable<any>} iterable\n */\nDeque.prototype.extendleft = function (iterable) {\n\tfor (const x of iterable) {\n\t\tthis.appendleft(x);\n\t}\n\n\treturn this;\n};\n\n/**\n * Deque.prototype._checkbounds.\n *\n * @param {Number} i\n */\nDeque.prototype._checkbounds = function (i) {\n\tif (i < 0 || i >= this.len()) {\n\t\tthrow new IndexError(i);\n\t}\n};\n\n/**\n * Deque.prototype._where.\n *\n * @param {Number} _i\n * @return {Array}\n */\nDeque.prototype._where = function (_i) {\n\tthrow new NotImplementedError('_where');\n};\n\n/**\n * Deque.prototype.get.\n *\n * @param {Number} i\n * @return {any}\n */\nDeque.prototype.get = function (i) {\n\tconst [container, index] = this._where(i);\n\n\treturn container[index];\n};\n\n/**\n * Deque.prototype.set.\n *\n * @param {Number} i\n * @param {any} value\n * @return {Deque}\n */\nDeque.prototype.set = function (i, value) {\n\tconst [container, index] = this._where(i);\n\n\tcontainer[index] = value;\n\n\treturn this;\n};\n\n/**\n * Deque.prototype._range\n *\n * @param {Number} start\n * @param {Number} stop\n * @return {Iterable<any>}\n */\nDeque.prototype._range = function* (start, stop) {\n\tfor (let i = start; i < stop; ++i) {\n\t\tyield [i, this.get(i)];\n\t}\n};\n\n/**\n * Deque.prototype.index.\n *\n * @param {any} x\n * @param {Number} start\n * @param {Number} stop\n */\nDeque.prototype.index = function (x, start = 0, stop = this.len()) {\n\tfor (const [i, element] of this._range(start, stop)) {\n\t\tif (element === x) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\tthrow new ValueError('not found');\n};\n\n/**\n * Deque.prototype.pop.\n *\n * @return {any}\n */\nDeque.prototype.pop = function () {\n\tthrow new NotImplementedError('pop');\n};\n\n/**\n * Deque.prototype.popleft.\n *\n * @return {any}\n */\nDeque.prototype.popleft = function () {\n\tthrow new NotImplementedError('popleft');\n};\n\n/**\n * Deque.prototype.insert.\n *\n * @param {Number} i\n * @param {any} x\n */\nDeque.prototype.insert = function (i, x) {\n\tthis._checkbounds(i);\n\n\tthis.append(x);\n\n\tlet j = this.len() - 1;\n\n\tfor (; i < j; --j) {\n\t\tconst a = this.get(j);\n\t\tthis.set(j, this.get(j - 1));\n\t\tthis.set(j - 1, a);\n\t}\n\n\treturn this;\n};\n\n/**\n * Deque.prototype.delete.\n *\n * @param {Number} i\n */\nDeque.prototype.delete = function (i) {\n\tthis._checkbounds(i);\n\n\tconst length = this.len() - 1;\n\n\tfor (; i < length; ++i) {\n\t\tthis.set(i, this.get(i + 1));\n\t}\n\n\tthis.pop();\n\n\treturn this;\n};\n\n/**\n * Deque.prototype.remove.\n *\n * @param {any} value\n */\nDeque.prototype.remove = function (value) {\n\tconst i = this.index(value);\n\n\tthis.delete(i);\n\n\treturn this;\n};\n\n/**\n * Deque.prototype.reverse.\n *\n * @return {Deque}\n */\nDeque.prototype.reverse = function () {\n\tfor (let i = 0, j = this.len(); i < --j; ++i) {\n\t\tconst a = this.get(i);\n\t\tconst b = this.get(j);\n\t\tthis.set(i, b);\n\t\tthis.set(j, a);\n\t}\n\n\treturn this;\n};\n\n/**\n * Deque.prototype.rotate.\n *\n * @param {Number} n\n */\nDeque.prototype.rotate = function (n) {\n\tif (n > 0) {\n\t\twhile (n-- > 0) {\n\t\t\tthis.appendleft(this.pop());\n\t\t}\n\t} else if (n < 0) {\n\t\twhile (n++ < 0) {\n\t\t\tthis.append(this.popleft());\n\t\t}\n\t}\n\n\treturn this;\n};\n","import {NotImplementedError} from '@failure-abstraction/error';\nimport Deque from './Deque.js';\n\n/**\n * ArbitrarySizeDeque.\n */\nexport default function ArbitrarySizeDeque() {}\n\nArbitrarySizeDeque.prototype = new Deque();\n\nArbitrarySizeDeque.prototype.values = function* () {\n\tlet i = this._center;\n\tconst _m = i + this.length;\n\tconst m = Math.min(this.capacity(), _m);\n\n\tfor (; i < m; ++i) {\n\t\tyield this._container[i];\n\t}\n\n\tconst n = _m % this.capacity();\n\n\tif (n < _m) {\n\t\tfor (i = 0; i < n; ++i) {\n\t\t\tyield this._container[i];\n\t\t}\n\t}\n};\n\n/**\n * ArbitrarySizeDeque.prototype._popindex.\n *\n * @param {any} _container\n * @param {Number} _index\n * @return {any}\n */\nArbitrarySizeDeque.prototype._popindex = function (_container, _index) {\n\tthrow new NotImplementedError('_popindex');\n};\n\nArbitrarySizeDeque.prototype.pop = function () {\n\tconst [container, index] = this._where(this.length - 1);\n\n\treturn this._popindex(container, index);\n};\n\nArbitrarySizeDeque.prototype.popleft = function () {\n\tconst [container, index] = this._where(0);\n\n\t++this._center;\n\tthis._center %= this.capacity();\n\n\treturn this._popindex(container, index);\n};\n","import ArbitrarySizeDeque from './ArbitrarySizeDeque.js';\n\n/**\n * BoundedDeque.\n *\n * @param {Iterable<any>} iterable\n * @param {Number} maxlen\n */\nexport default function BoundedDeque(iterable, maxlen) {\n\tthis._maxlen = maxlen;\n\n\t// eslint-disable-next-line unicorn/no-new-array\n\tthis._container = new Array(maxlen);\n\n\tthis._center = 0;\n\n\tthis.length = 0;\n\n\tif (iterable !== null) {\n\t\tthis.extend(iterable);\n\t}\n}\n\nBoundedDeque.prototype = new ArbitrarySizeDeque();\n\nBoundedDeque.prototype.len = function () {\n\treturn this.length;\n};\n\nBoundedDeque.prototype.capacity = function () {\n\treturn this._maxlen;\n};\n\nBoundedDeque.prototype.append = function (x) {\n\tif (this.length === this._maxlen) {\n\t\tthis._container[this._center] = x;\n\t\t++this._center;\n\t\tthis._center %= this._maxlen;\n\t} else {\n\t\tconst i = (this._center + this.length) % this._maxlen;\n\t\tthis._container[i] = x;\n\t\t++this.length;\n\t}\n\n\treturn this;\n};\n\nBoundedDeque.prototype.appendleft = function (x) {\n\t--this._center;\n\tthis._center += this._maxlen;\n\tthis._center %= this._maxlen;\n\tthis._container[this._center] = x;\n\n\tif (this.length < this._maxlen) {\n\t\t++this.length;\n\t}\n\n\treturn this;\n};\n\nBoundedDeque.prototype.clear = function () {\n\tthis._center = 0;\n\n\tthis.length = 0;\n\n\t// eslint-disable-next-line unicorn/no-new-array\n\tthis._container = new Array(this._maxlen);\n\n\treturn this;\n};\n\nBoundedDeque.prototype.copy = function () {\n\treturn new BoundedDeque(this, this._maxlen);\n};\n\nBoundedDeque.prototype._where = function (i) {\n\tthis._checkbounds(i);\n\n\treturn [this._container, (this._center + i) % this._maxlen];\n};\n\n/**\n * BoundedDeque.prototype._popindex.\n *\n * @param {any} container\n * @param {Number} index\n * @return {any}\n */\nBoundedDeque.prototype._popindex = function (container, index) {\n\tconst value = container[index];\n\n\t// GC\n\t// TODO use null instead of 0 for non-Number deques\n\tcontainer[index] = 0;\n\n\t--this.length;\n\n\treturn value;\n};\n","import {IndexError} from '@failure-abstraction/error';\nimport Deque from './Deque.js';\n\n/**\n * EmptyDeque.\n *\n * @param {Iterable<any>} iterable\n */\nexport default function EmptyDeque(iterable) {\n\tif (iterable !== null) {\n\t\tthis.extend(iterable);\n\t}\n}\n\nEmptyDeque.prototype = new Deque();\n\nEmptyDeque.prototype.len = function () {\n\treturn 0;\n};\n\nEmptyDeque.prototype.capacity = function () {\n\treturn 0;\n};\n\nEmptyDeque.prototype.values = function () {\n\treturn {\n\t\tnext() {\n\t\t\treturn {done: true};\n\t\t},\n\t};\n};\n\nEmptyDeque.prototype.append = function (_x) {\n\treturn this;\n};\n\nEmptyDeque.prototype.appendleft = function (_x) {\n\treturn this;\n};\n\nEmptyDeque.prototype.clear = function () {\n\treturn this;\n};\n\nEmptyDeque.prototype.copy = function () {\n\treturn new EmptyDeque(this);\n};\n\nEmptyDeque.prototype._where = function (i) {\n\tthrow new IndexError(i);\n};\n\nEmptyDeque.prototype.pop =\n\t// eslint-disable-next-line no-multi-assign\n\tEmptyDeque.prototype.popleft = function () {\n\t\tthrow new IndexError('pop / popleft');\n\t};\n","import {IndexError} from '@failure-abstraction/error';\nimport Deque from './Deque.js';\n\n/**\n * SingleElementDeque.\n *\n * @param {Iterable<any>} iterable\n */\nexport default function SingleElementDeque(iterable) {\n\tthis._empty = true;\n\n\tthis._value = 0;\n\n\tif (iterable !== null) {\n\t\tthis.extend(iterable);\n\t}\n}\n\nSingleElementDeque.prototype = new Deque();\n\nSingleElementDeque.prototype.len = function () {\n\treturn this._empty ? 0 : 1;\n};\n\nSingleElementDeque.prototype.capacity = function () {\n\treturn 1;\n};\n\nSingleElementDeque.prototype.values = function* () {\n\tif (this._empty) {\n\t\treturn;\n\t}\n\n\tyield this._value;\n};\n\nSingleElementDeque.prototype.append =\n\t// eslint-disable-next-line no-multi-assign\n\tSingleElementDeque.prototype.appendleft = function (x) {\n\t\tthis._empty = false;\n\t\tthis._value = x;\n\n\t\treturn this;\n\t};\n\nSingleElementDeque.prototype.clear = function () {\n\tthis._empty = true;\n\tthis._value = 0;\n\n\treturn this;\n};\n\nSingleElementDeque.prototype.copy = function () {\n\treturn new SingleElementDeque(this);\n};\n\nSingleElementDeque.prototype.pop =\n\t// eslint-disable-next-line no-multi-assign\n\tSingleElementDeque.prototype.popleft = function () {\n\t\tif (this._empty) {\n\t\t\tthrow new IndexError('pop / popleft');\n\t\t}\n\n\t\tconst value = this._value;\n\n\t\tthis._empty = true;\n\t\tthis._value = 0;\n\n\t\treturn value;\n\t};\n\nSingleElementDeque.prototype.get = function (i) {\n\tif (this._empty || i !== 0) {\n\t\tthrow new IndexError(i);\n\t}\n\n\treturn this._value;\n};\n\nSingleElementDeque.prototype.set = function (i, value) {\n\tif (this._empty || i !== 0) {\n\t\tthrow new IndexError(i);\n\t}\n\n\tthis._value = value;\n\n\treturn this;\n};\n","import ArbitrarySizeDeque from './ArbitrarySizeDeque.js';\n\n/**\n * UnboundedDeque.\n *\n * @param {Iterable<any>} iterable\n */\nexport default function UnboundedDeque(iterable) {\n\tthis._growth = 2;\n\n\tthis._minsize = 10;\n\n\tthis._currentsize = this._minsize;\n\n\t// eslint-disable-next-line unicorn/no-new-array\n\tthis._container = new Array(this._currentsize);\n\n\tthis._center = 0;\n\n\tthis.length = 0;\n\n\tif (iterable !== null) {\n\t\tthis.extend(iterable);\n\t}\n}\n\nUnboundedDeque.prototype = new ArbitrarySizeDeque();\n\nUnboundedDeque.prototype._copy = function (container) {\n\tconst length = this.length;\n\n\tfor (let i = 0; i < length; ++i) {\n\t\tcontainer[i] = this.get(i);\n\t}\n};\n\nUnboundedDeque.prototype._realloc = function (newsize) {\n\t// eslint-disable-next-line unicorn/no-new-array\n\tconst container = new Array(newsize);\n\n\tthis._copy(container);\n\n\tthis._container = container;\n\n\tthis._center = 0;\n\n\tthis._currentsize = newsize;\n};\n\nUnboundedDeque.prototype._shrink = function () {\n\tconst newsize = Math.max(this._minsize, this.length * this._growth);\n\n\tif (newsize * this._growth >= this._currentsize) {\n\t\treturn;\n\t}\n\n\tthis._realloc(newsize);\n};\n\nUnboundedDeque.prototype._grow = function (newlen) {\n\tif (newlen <= this._currentsize) {\n\t\treturn;\n\t}\n\n\tthis._realloc(newlen * this._growth);\n};\n\nUnboundedDeque.prototype.len = function () {\n\treturn this.length;\n};\n\nUnboundedDeque.prototype.capacity = function () {\n\treturn this._currentsize;\n};\n\nUnboundedDeque.prototype.append = function (x) {\n\tthis._grow(this.length + 1);\n\n\tconst i = (this._center + this.length) % this._currentsize;\n\tthis._container[i] = x;\n\t++this.length;\n\n\treturn this;\n};\n\nUnboundedDeque.prototype.appendleft = function (x) {\n\tthis._grow(this.length + 1);\n\n\t--this._center;\n\tthis._center += this._currentsize;\n\tthis._center %= this._currentsize;\n\tthis._container[this._center] = x;\n\n\t++this.length;\n\n\treturn this;\n};\n\nUnboundedDeque.prototype.clear = function () {\n\tthis._currentsize = this._minsize;\n\n\t// eslint-disable-next-line unicorn/no-new-array\n\tthis._container = new Array(this._currentsize);\n\n\tthis._center = 0;\n\n\tthis.length = 0;\n\n\treturn this;\n};\n\nUnboundedDeque.prototype.copy = function () {\n\treturn new UnboundedDeque(this);\n};\n\nUnboundedDeque.prototype._where = function (i) {\n\tthis._checkbounds(i);\n\n\treturn [this._container, (this._center + i) % this._currentsize];\n};\n\nUnboundedDeque.prototype._popindex = function (container, index) {\n\tconst value = container[index];\n\n\t// GC\n\t// TODO use null instead of 0 for non-Number deques\n\tcontainer[index] = 0;\n\n\t--this.length;\n\n\tthis._shrink();\n\n\treturn value;\n};\n","import {TypeError, ValueError} from '@failure-abstraction/error';\n\n/**\n * _deque.\n *\n * @param {Deque} UnboundedDeque\n * @param {Deque} BoundedDeque\n * @param {Deque} SingleElementDeque\n * @param {Deque} EmptyDeque\n */\nexport default function _deque(\n\tUnboundedDeque,\n\tBoundedDeque,\n\tSingleElementDeque,\n\tEmptyDeque,\n) {\n\t/**\n\t * Deque.\n\t *\n\t * @param {Iterable<any>} iterable\n\t * @param {Number} maxlen\n\t */\n\tconst deque = (iterable = null, maxlen = null) => {\n\t\tif (maxlen === null) {\n\t\t\treturn new UnboundedDeque(iterable);\n\t\t}\n\n\t\tif (!Number.isInteger(maxlen)) {\n\t\t\tthrow new TypeError(maxlen);\n\t\t}\n\n\t\tif (maxlen === 0) {\n\t\t\treturn new EmptyDeque(iterable);\n\t\t}\n\n\t\tif (maxlen === 1) {\n\t\t\treturn new SingleElementDeque(iterable);\n\t\t}\n\n\t\tif (maxlen > 0) {\n\t\t\treturn new BoundedDeque(iterable, maxlen);\n\t\t}\n\n\t\tthrow new ValueError(maxlen);\n\t};\n\n\treturn deque;\n}\n","import UnboundedDeque from './implementation/UnboundedDeque.js';\nimport BoundedDeque from './implementation/BoundedDeque.js';\nimport SingleElementDeque from './implementation/SingleElementDeque.js';\nimport EmptyDeque from './implementation/EmptyDeque.js';\n\nimport _deque from './_deque.js';\n\nconst deque = _deque(\n\tUnboundedDeque,\n\tBoundedDeque,\n\tSingleElementDeque,\n\tEmptyDeque,\n);\n\nexport default deque;\n"],"names":["Deque","ArbitrarySizeDeque","BoundedDeque","iterable","maxlen","this","_maxlen","_container","Array","_center","length","extend","EmptyDeque","SingleElementDeque","_empty","_value","UnboundedDeque","_growth","_minsize","_currentsize","_deque","Number","isInteger","TypeError","ValueError","prototype","len","NotImplementedError","capacity","empty","Symbol","iterator","values","append","_x","appendleft","clear","copy","count","x","c","extendleft","_checkbounds","i","IndexError","_where","_i","get","set","value","_range","start","stop","index","pop","popleft","insert","j","a","delete","remove","reverse","b","rotate","n","_m","m","Math","min","_popindex","_index","container","next","done","_copy","_realloc","newsize","_shrink","max","_grow","newlen","deque"],"mappings":"22BASwBA,cCHAC,cCEAC,EAAaC,EAAUC,GAC9CC,KAAKC,EAAUF,EAGfC,KAAKE,EAAa,IAAIC,MAAMJ,GAE5BC,KAAKI,EAAU,EAEfJ,KAAKK,OAAS,EAEG,OAAbP,GACHE,KAAKM,OAAOR,YCXUS,EAAWT,GACjB,OAAbA,GACHE,KAAKM,OAAOR,YCFUU,EAAmBV,GAC1CE,KAAKS,GAAS,EAEdT,KAAKU,EAAS,EAEG,OAAbZ,GACHE,KAAKM,OAAOR,YCPUa,EAAeb,GACtCE,KAAKY,EAAU,EAEfZ,KAAKa,EAAW,GAEhBb,KAAKc,EAAed,KAAKa,EAGzBb,KAAKE,EAAa,IAAIC,MAAMH,KAAKc,GAEjCd,KAAKI,EAAU,EAEfJ,KAAKK,OAAS,EAEG,OAAbP,GACHE,KAAKM,OAAOR,YCZUiB,EACvBJ,EACAd,EACAW,EACAD,GAgCA,OAxBc,SAACT,EAAiBC,GAC/B,YADcD,IAAAA,EAAW,eAAMC,IAAAA,EAAS,MACzB,OAAXA,EACH,WAAWY,EAAeb,GAG3B,IAAKkB,OAAOC,UAAUlB,GACrB,UAAUmB,YAAUnB,GAGrB,GAAe,IAAXA,EACH,WAAWQ,EAAWT,GAGvB,GAAe,IAAXC,EACH,WAAWS,EAAmBV,GAG/B,GAAIC,EAAS,EACZ,WAAWF,EAAaC,E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