mirror of
https://github.com/JasonYANG170/IOTConnect-Web.git
synced 2024-11-27 22:26:32 +00:00
1 line
19 KiB
Plaintext
1 line
19 KiB
Plaintext
{"version":3,"sources":["container/HashContainer/Base/index.js","../../src/container/HashContainer/Base/index.ts"],"names":["__extends","this","extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","prototype","hasOwnProperty","call","TypeError","String","__","constructor","create","Container","ContainerIterator","checkObject","throwIteratorAccessError","HashContainerIterator","_super","node","header","iteratorType","_this","_node","_header","pre","_pre","next","_next","HashContainer","_objMap","_originMap","HASH_TAG","Symbol","_head","_tail","_eraseNode","_length","_set","key","value","isObject","undefined","newTail","index","_value","defineProperty","length","configurable","_key","push","_findElementNode","clear","forEach","el","eraseElementByKey","eraseElementByIterator","iter","eraseElementByPos","pos","RangeError"],"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,YAAYN,MAAM,OAAOC,OAAOY,OAAOb,MAAMW,GAAGL,YAAYN,EAAEM,WAAW,IAAIK;AACnF;AACJ,CAd6C;;SCApCG,WAAWC,yBAAiC;;OAC9CC,iBAAW;;SAETC,gCAA0B;;AASnC,IAAAC,wBAAA,SAAAC;IAA0DvB,UA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AAS;YACzBR;ADLE;QCOJpB,KAAKwC,EAAWjB;QAChB,OAAOsC,EAAK9B;ADLZ;ICOFE,cAAAxB,UAAAqD,oBAAA,SAAkBC;QDLZ,ICMsBA,IAAG,KAAHA,IAAQ/D,KAAKyC,IAAO,GAvN5C;YAAG,MAAS,IAAIuB;ADmNd;QCKJ,IAAIzC,IAAOvB,KAAKsC;QAChB,OAAOyB,KAAO;YACZxC,IAAOA,EAAKS;ADHV;QCKJhC,KAAKwC,EAAWjB;QAChB,OAAOvB,KAAKyC;ADHZ;ICKJ,OAAAR;AAAA,CAjKA,CAAkDhB;;SD+JzCgB","file":"index.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})();\nimport { Container, ContainerIterator } from \"../../ContainerBase\";\nimport checkObject from \"../../../utils/checkObject\";\nimport $checkWithinAccessParams from \"../../../utils/checkParams.macro\";\nimport { throwIteratorAccessError } from \"../../../utils/throwError\";\nvar HashContainerIterator = /** @class */ (function (_super) {\n __extends(HashContainerIterator, _super);\n /**\n * @internal\n */\n function HashContainerIterator(node, header, iteratorType) {\n var _this = _super.call(this, iteratorType) || this;\n _this._node = node;\n _this._header = header;\n if (_this.iteratorType === 0 /* IteratorType.NORMAL */) {\n _this.pre = function () {\n if (this._node._pre === this._header) {\n throwIteratorAccessError();\n }\n this._node = this._node._pre;\n return this;\n };\n _this.next = function () {\n if (this._node === this._header) {\n throwIteratorAccessError();\n }\n this._node = this._node._next;\n return this;\n };\n }\n else {\n _this.pre = function () {\n if (this._node._next === this._header) {\n throwIteratorAccessError();\n }\n this._node = this._node._next;\n return this;\n };\n _this.next = function () {\n if (this._node === this._header) {\n throwIteratorAccessError();\n }\n this._node = this._node._pre;\n return this;\n };\n }\n return _this;\n }\n return HashContainerIterator;\n}(ContainerIterator));\nexport { HashContainerIterator };\nvar HashContainer = /** @class */ (function (_super) {\n __extends(HashContainer, _super);\n /**\n * @internal\n */\n function HashContainer() {\n var _this = _super.call(this) || this;\n /**\n * @internal\n */\n _this._objMap = [];\n /**\n * @internal\n */\n _this._originMap = {};\n /**\n * @description Unique symbol used to tag object.\n */\n _this.HASH_TAG = Symbol('@@HASH_TAG');\n Object.setPrototypeOf(_this._originMap, null);\n _this._header = {};\n _this._header._pre = _this._header._next = _this._head = _this._tail = _this._header;\n return _this;\n }\n /**\n * @internal\n */\n HashContainer.prototype._eraseNode = function (node) {\n var _pre = node._pre, _next = node._next;\n _pre._next = _next;\n _next._pre = _pre;\n if (node === this._head) {\n this._head = _next;\n }\n if (node === this._tail) {\n this._tail = _pre;\n }\n this._length -= 1;\n };\n /**\n * @internal\n */\n HashContainer.prototype._set = function (key, value, isObject) {\n if (isObject === undefined)\n isObject = checkObject(key);\n var newTail;\n if (isObject) {\n var index = key[this.HASH_TAG];\n if (index !== undefined) {\n this._objMap[index]._value = value;\n return this._length;\n }\n Object.defineProperty(key, this.HASH_TAG, {\n value: this._objMap.length,\n configurable: true\n });\n newTail = {\n _key: key,\n _value: value,\n _pre: this._tail,\n _next: this._header\n };\n this._objMap.push(newTail);\n }\n else {\n var node = this._originMap[key];\n if (node) {\n node._value = value;\n return this._length;\n }\n newTail = {\n _key: key,\n _value: value,\n _pre: this._tail,\n _next: this._header\n };\n this._originMap[key] = newTail;\n }\n if (this._length === 0) {\n this._head = newTail;\n this._header._next = newTail;\n }\n else {\n this._tail._next = newTail;\n }\n this._tail = newTail;\n this._header._pre = newTail;\n return ++this._length;\n };\n /**\n * @internal\n */\n HashContainer.prototype._findElementNode = function (key, isObject) {\n if (isObject === undefined)\n isObject = checkObject(key);\n if (isObject) {\n var index = key[this.HASH_TAG];\n if (index === undefined)\n return this._header;\n return this._objMap[index];\n }\n else {\n return this._originMap[key] || this._header;\n }\n };\n HashContainer.prototype.clear = function () {\n var HASH_TAG = this.HASH_TAG;\n this._objMap.forEach(function (el) {\n delete el._key[HASH_TAG];\n });\n this._objMap = [];\n this._originMap = {};\n Object.setPrototypeOf(this._originMap, null);\n this._length = 0;\n this._head = this._tail = this._header._pre = this._header._next = this._header;\n };\n /**\n * @description Remove the element of the specified key.\n * @param key - The key you want to remove.\n * @param isObject - Tell us if the type of inserted key is `object` to improve efficiency.<br/>\n * If a `undefined` value is passed in, the type will be automatically judged.\n * @returns Whether erase successfully.\n */\n HashContainer.prototype.eraseElementByKey = function (key, isObject) {\n var node;\n if (isObject === undefined)\n isObject = checkObject(key);\n if (isObject) {\n var index = key[this.HASH_TAG];\n if (index === undefined)\n return false;\n delete key[this.HASH_TAG];\n node = this._objMap[index];\n delete this._objMap[index];\n }\n else {\n node = this._originMap[key];\n if (node === undefined)\n return false;\n delete this._originMap[key];\n }\n this._eraseNode(node);\n return true;\n };\n HashContainer.prototype.eraseElementByIterator = function (iter) {\n var node = iter._node;\n if (node === this._header) {\n throwIteratorAccessError();\n }\n this._eraseNode(node);\n return iter.next();\n };\n HashContainer.prototype.eraseElementByPos = function (pos) {\n if (pos < 0 || pos > this._length - 1) {\n throw new RangeError();\n }\n var node = this._head;\n while (pos--) {\n node = node._next;\n }\n this._eraseNode(node);\n return this._length;\n };\n return HashContainer;\n}(Container));\nexport { HashContainer };\n","import { Container, ContainerIterator, IteratorType } from '@/container/ContainerBase';\nimport checkObject from '@/utils/checkObject';\nimport $checkWithinAccessParams from '@/utils/checkParams.macro';\nimport { throwIteratorAccessError } from '@/utils/throwError';\n\nexport type HashLinkNode<K, V> = {\n _key: K,\n _value: V,\n _pre: HashLinkNode<K, V>,\n _next: HashLinkNode<K, V>\n}\n\nexport abstract class HashContainerIterator<K, V> extends ContainerIterator<K | [K, V]> {\n abstract readonly container: HashContainer<K, V>;\n /**\n * @internal\n */\n _node: HashLinkNode<K, V>;\n /**\n * @internal\n */\n protected readonly _header: HashLinkNode<K, V>;\n /**\n * @internal\n */\n protected constructor(\n node: HashLinkNode<K, V>,\n header: HashLinkNode<K, V>,\n iteratorType?: IteratorType\n ) {\n super(iteratorType);\n this._node = node;\n this._header = header;\n if (this.iteratorType === IteratorType.NORMAL) {\n this.pre = function () {\n if (this._node._pre === this._header) {\n throwIteratorAccessError();\n }\n this._node = this._node._pre;\n return this;\n };\n this.next = function () {\n if (this._node === this._header) {\n throwIteratorAccessError();\n }\n this._node = this._node._next;\n return this;\n };\n } else {\n this.pre = function () {\n if (this._node._next === this._header) {\n throwIteratorAccessError();\n }\n this._node = this._node._next;\n return this;\n };\n this.next = function () {\n if (this._node === this._header) {\n throwIteratorAccessError();\n }\n this._node = this._node._pre;\n return this;\n };\n }\n }\n // @ts-ignore\n pre(): this;\n // @ts-ignore\n next(): this;\n}\n\nexport abstract class HashContainer<K, V> extends Container<K | [K, V]> {\n /**\n * @internal\n */\n protected _objMap: HashLinkNode<K, V>[] = [];\n /**\n * @internal\n */\n protected _originMap: Record<string, HashLinkNode<K, V>> = {};\n /**\n * @internal\n */\n protected _head: HashLinkNode<K, V>;\n /**\n * @internal\n */\n protected _tail: HashLinkNode<K, V>;\n /**\n * @internal\n */\n protected readonly _header: HashLinkNode<K, V>;\n /**\n * @description Unique symbol used to tag object.\n */\n readonly HASH_TAG = Symbol('@@HASH_TAG');\n /**\n * @internal\n */\n protected constructor() {\n super();\n Object.setPrototypeOf(this._originMap, null);\n this._header = <HashLinkNode<K, V>>{};\n this._header._pre = this._header._next = this._head = this._tail = this._header;\n }\n /**\n * @internal\n */\n protected _eraseNode(node: HashLinkNode<K, V>) {\n const { _pre, _next } = node;\n _pre._next = _next;\n _next._pre = _pre;\n if (node === this._head) {\n this._head = _next;\n }\n if (node === this._tail) {\n this._tail = _pre;\n }\n this._length -= 1;\n }\n /**\n * @internal\n */\n protected _set(key: K, value?: V, isObject?: boolean) {\n if (isObject === undefined) isObject = checkObject(key);\n let newTail;\n if (isObject) {\n const index = (<Record<symbol, number>><unknown>key)[this.HASH_TAG];\n if (index !== undefined) {\n this._objMap[<number>index]._value = <V>value;\n return this._length;\n }\n Object.defineProperty(key, this.HASH_TAG, {\n value: this._objMap.length,\n configurable: true\n });\n newTail = {\n _key: key,\n _value: <V>value,\n _pre: this._tail,\n _next: this._header\n };\n this._objMap.push(newTail);\n } else {\n const node = this._originMap[<string><unknown>key];\n if (node) {\n node._value = <V>value;\n return this._length;\n }\n newTail = {\n _key: key,\n _value: <V>value,\n _pre: this._tail,\n _next: this._header\n };\n this._originMap[<string><unknown>key] = newTail;\n }\n if (this._length === 0) {\n this._head = newTail;\n this._header._next = newTail;\n } else {\n this._tail._next = newTail;\n }\n this._tail = newTail;\n this._header._pre = newTail;\n return ++this._length;\n }\n /**\n * @internal\n */\n protected _findElementNode(key: K, isObject?: boolean) {\n if (isObject === undefined) isObject = checkObject(key);\n if (isObject) {\n const index = (<Record<symbol, number>><unknown>key)[this.HASH_TAG];\n if (index === undefined) return this._header;\n return this._objMap[index];\n } else {\n return this._originMap[<string><unknown>key] || this._header;\n }\n }\n clear() {\n const HASH_TAG = this.HASH_TAG;\n this._objMap.forEach(function (el) {\n delete (<Record<symbol, number>><unknown>el._key)[HASH_TAG];\n });\n this._objMap = [];\n this._originMap = {};\n Object.setPrototypeOf(this._originMap, null);\n this._length = 0;\n this._head = this._tail = this._header._pre = this._header._next = this._header;\n }\n /**\n * @description Remove the element of the specified key.\n * @param key - The key you want to remove.\n * @param isObject - Tell us if the type of inserted key is `object` to improve efficiency.<br/>\n * If a `undefined` value is passed in, the type will be automatically judged.\n * @returns Whether erase successfully.\n */\n eraseElementByKey(key: K, isObject?: boolean) {\n let node;\n if (isObject === undefined) isObject = checkObject(key);\n if (isObject) {\n const index = (<Record<symbol, number>><unknown>key)[this.HASH_TAG];\n if (index === undefined) return false;\n delete (<Record<symbol, number>><unknown>key)[this.HASH_TAG];\n node = this._objMap[index];\n delete this._objMap[index];\n } else {\n node = this._originMap[<string><unknown>key];\n if (node === undefined) return false;\n delete this._originMap[<string><unknown>key];\n }\n this._eraseNode(node);\n return true;\n }\n eraseElementByIterator(iter: HashContainerIterator<K, V>) {\n const node = iter._node;\n if (node === this._header) {\n throwIteratorAccessError();\n }\n this._eraseNode(node);\n return iter.next();\n }\n eraseElementByPos(pos: number) {\n $checkWithinAccessParams!(pos, 0, this._length - 1);\n let node = this._head;\n while (pos--) {\n node = node._next;\n }\n this._eraseNode(node);\n return this._length;\n }\n}\n"]} |