mirror of
https://github.com/JasonYANG170/IOTConnect-Web.git
synced 2024-11-24 04:36:31 +00:00
1 line
22 KiB
Plaintext
1 line
22 KiB
Plaintext
{"version":3,"sources":["container/TreeContainer/OrderedMap.js","../../src/container/TreeContainer/OrderedMap.ts"],"names":["__extends","this","extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","prototype","hasOwnProperty","call","TypeError","String","__","constructor","create","__generator","thisArg","body","_","label","sent","t","trys","ops","f","y","g","next","verb","throw","return","Symbol","iterator","n","v","step","op","done","value","pop","length","push","e","__values","o","s","m","i","TreeContainer","TreeIterator","throwIteratorAccessError","OrderedMapIterator","_super","node","header","container","iteratorType","_this","defineProperty","get","_node","_header","self","Proxy","props","_key","_value","set","newValue","enumerable","configurable","copy","OrderedMap","cmp","enableIndex","forEach","el","setElement","_iterationFunc","curNode","_a","undefined","_left","_right","begin","end","rBegin","rEnd","front","_length","minNode","back","maxNode","lowerBound","key","resNode","_lowerBound","_root","upperBound","_upperBound","reverseLowerBound","_reverseLowerBound","reverseUpperBound","_reverseUpperBound","hint","_set","find","_findElementNode","getElementByKey","union","other"],"mappings":"AAAA,IAAIA,YAAaC,QAAQA,KAAKD,KAAe;IACzC,IAAIE,gBAAgB,SAAUC,GAAGC;QAC7BF,gBAAgBG,OAAOC,kBAClB;YAAEC,WAAW;qBAAgBC,SAAS,SAAUL,GAAGC;YAAKD,EAAEI,YAAYH;AAAG,aAC1E,SAAUD,GAAGC;YAAK,KAAK,IAAIK,KAAKL,GAAG,IAAIC,OAAOK,UAAUC,eAAeC,KAAKR,GAAGK,IAAIN,EAAEM,KAAKL,EAAEK;AAAI;QACpG,OAAOP,cAAcC,GAAGC;AAC5B;IACA,OAAO,SAAUD,GAAGC;QAChB,WAAWA,MAAM,cAAcA,MAAM,MACjC,MAAM,IAAIS,UAAU,yBAAyBC,OAAOV,KAAK;QAC7DF,cAAcC,GAAGC;QACjB,SAASW;YAAOd,KAAKe,cAAcb;AAAG;QACtCA,EAAEO,YAAY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EAAG,IAAIA,EAAG;ADmDxB;QCjDJ,OAAO9E,KAAK2F;ADmDZ;ICjDFjB,WAAAjE,UAACwB,OAAOC,YAAR;QACE,OAAOlC,KAAKgF,EAAehF,KAAKmG;ADmDhC;IC3CJ,OAAAzB;AAAA,CAzHA,CAA+BxB;;eA2HhBwB","file":"OrderedMap.js","sourcesContent":["var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n};\nimport TreeContainer from './Base';\nimport TreeIterator from './Base/TreeIterator';\nimport { throwIteratorAccessError } from \"../../utils/throwError\";\nvar OrderedMapIterator = /** @class */ (function (_super) {\n __extends(OrderedMapIterator, _super);\n function OrderedMapIterator(node, header, container, iteratorType) {\n var _this = _super.call(this, node, header, iteratorType) || this;\n _this.container = container;\n return _this;\n }\n Object.defineProperty(OrderedMapIterator.prototype, \"pointer\", {\n get: function () {\n if (this._node === this._header) {\n throwIteratorAccessError();\n }\n var self = this;\n return new Proxy([], {\n get: function (_, props) {\n if (props === '0')\n return self._node._key;\n else if (props === '1')\n return self._node._value;\n },\n set: function (_, props, newValue) {\n if (props !== '1') {\n throw new TypeError('props must be 1');\n }\n self._node._value = newValue;\n return true;\n }\n });\n },\n enumerable: false,\n configurable: true\n });\n OrderedMapIterator.prototype.copy = function () {\n return new OrderedMapIterator(this._node, this._header, this.container, this.iteratorType);\n };\n return OrderedMapIterator;\n}(TreeIterator));\nvar OrderedMap = /** @class */ (function (_super) {\n __extends(OrderedMap, _super);\n /**\n * @param container - The initialization container.\n * @param cmp - The compare function.\n * @param enableIndex - Whether to enable iterator indexing function.\n * @example\n * new OrderedMap();\n * new OrderedMap([[0, 1], [2, 1]]);\n * new OrderedMap([[0, 1], [2, 1]], (x, y) => x - y);\n * new OrderedMap([[0, 1], [2, 1]], (x, y) => x - y, true);\n */\n function OrderedMap(container, cmp, enableIndex) {\n if (container === void 0) { container = []; }\n var _this = _super.call(this, cmp, enableIndex) || this;\n var self = _this;\n container.forEach(function (el) {\n self.setElement(el[0], el[1]);\n });\n return _this;\n }\n /**\n * @internal\n */\n OrderedMap.prototype._iterationFunc = function (curNode) {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (curNode === undefined)\n return [2 /*return*/];\n return [5 /*yield**/, __values(this._iterationFunc(curNode._left))];\n case 1:\n _a.sent();\n return [4 /*yield*/, [curNode._key, curNode._value]];\n case 2:\n _a.sent();\n return [5 /*yield**/, __values(this._iterationFunc(curNode._right))];\n case 3:\n _a.sent();\n return [2 /*return*/];\n }\n });\n };\n OrderedMap.prototype.begin = function () {\n return new OrderedMapIterator(this._header._left || this._header, this._header, this);\n };\n OrderedMap.prototype.end = function () {\n return new OrderedMapIterator(this._header, this._header, this);\n };\n OrderedMap.prototype.rBegin = function () {\n return new OrderedMapIterator(this._header._right || this._header, this._header, this, 1 /* IteratorType.REVERSE */);\n };\n OrderedMap.prototype.rEnd = function () {\n return new OrderedMapIterator(this._header, this._header, this, 1 /* IteratorType.REVERSE */);\n };\n OrderedMap.prototype.front = function () {\n if (this._length === 0)\n return;\n var minNode = this._header._left;\n return [minNode._key, minNode._value];\n };\n OrderedMap.prototype.back = function () {\n if (this._length === 0)\n return;\n var maxNode = this._header._right;\n return [maxNode._key, maxNode._value];\n };\n OrderedMap.prototype.lowerBound = function (key) {\n var resNode = this._lowerBound(this._root, key);\n return new OrderedMapIterator(resNode, this._header, this);\n };\n OrderedMap.prototype.upperBound = function (key) {\n var resNode = this._upperBound(this._root, key);\n return new OrderedMapIterator(resNode, this._header, this);\n };\n OrderedMap.prototype.reverseLowerBound = function (key) {\n var resNode = this._reverseLowerBound(this._root, key);\n return new OrderedMapIterator(resNode, this._header, this);\n };\n OrderedMap.prototype.reverseUpperBound = function (key) {\n var resNode = this._reverseUpperBound(this._root, key);\n return new OrderedMapIterator(resNode, this._header, this);\n };\n /**\n * @description Insert a key-value pair or set value by the given key.\n * @param key - The key want to insert.\n * @param value - The value want to set.\n * @param hint - You can give an iterator hint to improve insertion efficiency.\n * @return The size of container after setting.\n * @example\n * const mp = new OrderedMap([[2, 0], [4, 0], [5, 0]]);\n * const iter = mp.begin();\n * mp.setElement(1, 0);\n * mp.setElement(3, 0, iter); // give a hint will be faster.\n */\n OrderedMap.prototype.setElement = function (key, value, hint) {\n return this._set(key, value, hint);\n };\n OrderedMap.prototype.find = function (key) {\n var curNode = this._findElementNode(this._root, key);\n return new OrderedMapIterator(curNode, this._header, this);\n };\n /**\n * @description Get the value of the element of the specified key.\n * @param key - The specified key you want to get.\n * @example\n * const val = container.getElementByKey(1);\n */\n OrderedMap.prototype.getElementByKey = function (key) {\n var curNode = this._findElementNode(this._root, key);\n return curNode._value;\n };\n OrderedMap.prototype.union = function (other) {\n var self = this;\n other.forEach(function (el) {\n self.setElement(el[0], el[1]);\n });\n return this._length;\n };\n OrderedMap.prototype[Symbol.iterator] = function () {\n return this._iterationFunc(this._root);\n };\n return OrderedMap;\n}(TreeContainer));\nexport default OrderedMap;\n","import TreeContainer from './Base';\nimport TreeIterator from './Base/TreeIterator';\nimport { TreeNode } from './Base/TreeNode';\nimport { initContainer, IteratorType } from '@/container/ContainerBase';\nimport { throwIteratorAccessError } from '@/utils/throwError';\n\nclass OrderedMapIterator<K, V> extends TreeIterator<K, V> {\n container: OrderedMap<K, V>;\n constructor(\n node: TreeNode<K, V>,\n header: TreeNode<K, V>,\n container: OrderedMap<K, V>,\n iteratorType?: IteratorType\n ) {\n super(node, header, iteratorType);\n this.container = container;\n }\n get pointer() {\n if (this._node === this._header) {\n throwIteratorAccessError();\n }\n const self = this;\n return new Proxy(<[K, V]><unknown>[], {\n get(_, props: '0' | '1') {\n if (props === '0') return self._node._key;\n else if (props === '1') return self._node._value;\n },\n set(_, props: '1', newValue: V) {\n if (props !== '1') {\n throw new TypeError('props must be 1');\n }\n self._node._value = newValue;\n return true;\n }\n });\n }\n copy() {\n return new OrderedMapIterator<K, V>(\n this._node,\n this._header,\n this.container,\n this.iteratorType\n );\n }\n // @ts-ignore\n equals(iter: OrderedMapIterator<K, V>): boolean;\n}\n\nexport type { OrderedMapIterator };\n\nclass OrderedMap<K, V> extends TreeContainer<K, V> {\n /**\n * @param container - The initialization container.\n * @param cmp - The compare function.\n * @param enableIndex - Whether to enable iterator indexing function.\n * @example\n * new OrderedMap();\n * new OrderedMap([[0, 1], [2, 1]]);\n * new OrderedMap([[0, 1], [2, 1]], (x, y) => x - y);\n * new OrderedMap([[0, 1], [2, 1]], (x, y) => x - y, true);\n */\n constructor(\n container: initContainer<[K, V]> = [],\n cmp?: (x: K, y: K) => number,\n enableIndex?: boolean\n ) {\n super(cmp, enableIndex);\n const self = this;\n container.forEach(function (el) {\n self.setElement(el[0], el[1]);\n });\n }\n /**\n * @internal\n */\n private * _iterationFunc(\n curNode: TreeNode<K, V> | undefined\n ): Generator<[K, V], void> {\n if (curNode === undefined) return;\n yield * this._iterationFunc(curNode._left);\n yield <[K, V]>[curNode._key, curNode._value];\n yield * this._iterationFunc(curNode._right);\n }\n begin() {\n return new OrderedMapIterator<K, V>(this._header._left || this._header, this._header, this);\n }\n end() {\n return new OrderedMapIterator<K, V>(this._header, this._header, this);\n }\n rBegin() {\n return new OrderedMapIterator<K, V>(\n this._header._right || this._header,\n this._header,\n this,\n IteratorType.REVERSE\n );\n }\n rEnd() {\n return new OrderedMapIterator<K, V>(this._header, this._header, this, IteratorType.REVERSE);\n }\n front() {\n if (this._length === 0) return;\n const minNode = this._header._left!;\n return <[K, V]>[minNode._key, minNode._value];\n }\n back() {\n if (this._length === 0) return;\n const maxNode = this._header._right!;\n return <[K, V]>[maxNode._key, maxNode._value];\n }\n lowerBound(key: K) {\n const resNode = this._lowerBound(this._root, key);\n return new OrderedMapIterator<K, V>(resNode, this._header, this);\n }\n upperBound(key: K) {\n const resNode = this._upperBound(this._root, key);\n return new OrderedMapIterator<K, V>(resNode, this._header, this);\n }\n reverseLowerBound(key: K) {\n const resNode = this._reverseLowerBound(this._root, key);\n return new OrderedMapIterator<K, V>(resNode, this._header, this);\n }\n reverseUpperBound(key: K) {\n const resNode = this._reverseUpperBound(this._root, key);\n return new OrderedMapIterator<K, V>(resNode, this._header, this);\n }\n /**\n * @description Insert a key-value pair or set value by the given key.\n * @param key - The key want to insert.\n * @param value - The value want to set.\n * @param hint - You can give an iterator hint to improve insertion efficiency.\n * @return The size of container after setting.\n * @example\n * const mp = new OrderedMap([[2, 0], [4, 0], [5, 0]]);\n * const iter = mp.begin();\n * mp.setElement(1, 0);\n * mp.setElement(3, 0, iter); // give a hint will be faster.\n */\n setElement(key: K, value: V, hint?: OrderedMapIterator<K, V>) {\n return this._set(key, value, hint);\n }\n find(key: K) {\n const curNode = this._findElementNode(this._root, key);\n return new OrderedMapIterator<K, V>(curNode, this._header, this);\n }\n /**\n * @description Get the value of the element of the specified key.\n * @param key - The specified key you want to get.\n * @example\n * const val = container.getElementByKey(1);\n */\n getElementByKey(key: K) {\n const curNode = this._findElementNode(this._root, key);\n return curNode._value;\n }\n union(other: OrderedMap<K, V>) {\n const self = this;\n other.forEach(function (el) {\n self.setElement(el[0], el[1]);\n });\n return this._length;\n }\n [Symbol.iterator]() {\n return this._iterationFunc(this._root);\n }\n // @ts-ignore\n eraseElementByIterator(iter: OrderedMapIterator<K, V>): OrderedMapIterator<K, V>;\n // @ts-ignore\n forEach(callback: (element: [K, V], index: number, map: OrderedMap<K, V>) => void): void;\n // @ts-ignore\n getElementByPos(pos: number): [K, V];\n}\n\nexport default OrderedMap;\n"]} |