data-structure-typed 2.5.1 → 2.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/MIGRATION.md +169 -0
- package/README.md +135 -23
- package/README_CN.md +551 -143
- package/SPECIFICATION.md +20 -14
- package/SPECIFICATION.zh-CN.md +20 -14
- package/dist/cjs/binary-tree.cjs +6460 -1591
- package/dist/cjs/graph.cjs +440 -20
- package/dist/cjs/hash.cjs +125 -22
- package/dist/cjs/heap.cjs +196 -47
- package/dist/cjs/index.cjs +8486 -2429
- package/dist/cjs/linked-list.cjs +456 -31
- package/dist/cjs/matrix.cjs +79 -9
- package/dist/cjs/priority-queue.cjs +193 -44
- package/dist/cjs/queue.cjs +391 -2
- package/dist/cjs/stack.cjs +92 -6
- package/dist/cjs/trie.cjs +122 -28
- package/dist/cjs-legacy/binary-tree.cjs +6484 -1612
- package/dist/cjs-legacy/graph.cjs +440 -20
- package/dist/cjs-legacy/hash.cjs +125 -22
- package/dist/cjs-legacy/heap.cjs +196 -47
- package/dist/cjs-legacy/index.cjs +8654 -2594
- package/dist/cjs-legacy/linked-list.cjs +456 -31
- package/dist/cjs-legacy/matrix.cjs +79 -9
- package/dist/cjs-legacy/priority-queue.cjs +193 -44
- package/dist/cjs-legacy/queue.cjs +391 -2
- package/dist/cjs-legacy/stack.cjs +92 -6
- package/dist/cjs-legacy/trie.cjs +122 -28
- package/dist/esm/binary-tree.mjs +6460 -1591
- package/dist/esm/graph.mjs +440 -20
- package/dist/esm/hash.mjs +125 -22
- package/dist/esm/heap.mjs +196 -47
- package/dist/esm/index.mjs +8486 -2430
- package/dist/esm/linked-list.mjs +456 -31
- package/dist/esm/matrix.mjs +79 -9
- package/dist/esm/priority-queue.mjs +193 -44
- package/dist/esm/queue.mjs +391 -2
- package/dist/esm/stack.mjs +92 -6
- package/dist/esm/trie.mjs +122 -28
- package/dist/esm-legacy/binary-tree.mjs +6484 -1612
- package/dist/esm-legacy/graph.mjs +440 -20
- package/dist/esm-legacy/hash.mjs +125 -22
- package/dist/esm-legacy/heap.mjs +196 -47
- package/dist/esm-legacy/index.mjs +8654 -2595
- package/dist/esm-legacy/linked-list.mjs +456 -31
- package/dist/esm-legacy/matrix.mjs +79 -9
- package/dist/esm-legacy/priority-queue.mjs +193 -44
- package/dist/esm-legacy/queue.mjs +391 -2
- package/dist/esm-legacy/stack.mjs +92 -6
- package/dist/esm-legacy/trie.mjs +122 -28
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +98 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +112 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +214 -13
- package/dist/types/data-structures/binary-tree/bst.d.ts +294 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +155 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +48 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1370 -323
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1329 -316
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +1116 -295
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1330 -326
- package/dist/types/data-structures/graph/directed-graph.d.ts +80 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +72 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +95 -6
- package/dist/types/data-structures/heap/heap.d.ts +154 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +143 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +144 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +64 -0
- package/dist/types/data-structures/queue/deque.d.ts +142 -0
- package/dist/types/data-structures/queue/queue.d.ts +109 -0
- package/dist/types/data-structures/stack/stack.d.ts +82 -2
- package/dist/types/data-structures/trie/trie.d.ts +96 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/umd/data-structure-typed.js +8623 -2564
- package/dist/umd/data-structure-typed.min.js +5 -5
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +696 -194
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +71 -71
- package/docs-site-docusaurus/docs/api/classes/BST.md +639 -189
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +15 -15
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +148 -160
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +105 -91
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +82 -82
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +104 -74
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +12 -12
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +51 -51
- package/docs-site-docusaurus/docs/api/classes/Heap.md +96 -85
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +25 -25
- package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +33 -33
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +50 -50
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +55 -55
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +55 -55
- package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +78 -78
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +82 -82
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +31 -31
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +103 -88
- package/docs-site-docusaurus/docs/api/classes/Queue.md +112 -60
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +708 -206
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +79 -79
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +44 -44
- package/docs-site-docusaurus/docs/api/classes/Stack.md +42 -42
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +236 -33
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +162 -46
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +232 -32
- package/docs-site-docusaurus/docs/api/classes/Trie.md +47 -47
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +81 -81
- package/docs-site-docusaurus/docs/guide/architecture.md +75 -5
- package/docs-site-docusaurus/docs/guide/concepts.md +53 -3
- package/docs-site-docusaurus/docs/guide/faq.md +233 -0
- package/docs-site-docusaurus/docs/guide/guides.md +43 -58
- package/docs-site-docusaurus/docs/guide/installation.md +2 -0
- package/docs-site-docusaurus/docs/guide/integrations.md +75 -176
- package/docs-site-docusaurus/docs/guide/overview.md +132 -11
- package/docs-site-docusaurus/docs/guide/performance.md +2 -0
- package/docs-site-docusaurus/docs/guide/quick-start.md +31 -0
- package/docs-site-docusaurus/docs/guide/use-cases/_category_.json +6 -0
- package/docs-site-docusaurus/docs/guide/use-cases/array-sort-alternative.md +158 -0
- package/docs-site-docusaurus/docs/guide/use-cases/heap-vs-sorting.md +92 -0
- package/docs-site-docusaurus/docs/guide/use-cases/map-vs-treemap.md +151 -0
- package/docs-site-docusaurus/docs/guide/use-cases/priority-queue-typescript.md +113 -0
- package/docs-site-docusaurus/docs/guide/use-cases/treemap-javascript.md +151 -0
- package/docs-site-docusaurus/docusaurus.config.ts +1 -1
- package/docs-site-docusaurus/src/pages/index.tsx +55 -2
- package/docs-site-docusaurus/static/llms.txt +37 -0
- package/docs-site-docusaurus/typedoc.json +1 -0
- package/llms.txt +37 -0
- package/package.json +65 -56
- package/src/common/error.ts +19 -1
- package/src/common/index.ts +1 -1
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/binary-tree/avl-tree.ts +99 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
- package/src/data-structures/binary-tree/binary-tree.ts +239 -78
- package/src/data-structures/binary-tree/bst.ts +542 -13
- package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
- package/src/data-structures/binary-tree/segment-tree.ts +42 -0
- package/src/data-structures/binary-tree/tree-map.ts +1223 -261
- package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
- package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
- package/src/data-structures/binary-tree/tree-set.ts +1018 -99
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +71 -1
- package/src/data-structures/graph/undirected-graph.ts +64 -1
- package/src/data-structures/hash/hash-map.ts +102 -16
- package/src/data-structures/heap/heap.ts +153 -23
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
- package/src/data-structures/matrix/matrix.ts +65 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +130 -0
- package/src/data-structures/queue/queue.ts +109 -0
- package/src/data-structures/stack/stack.ts +75 -5
- package/src/data-structures/trie/trie.ts +86 -2
- package/src/interfaces/binary-tree.ts +1 -9
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
- package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +0 -12984
- package/.vitepress/cache/deps_temp_51f5f1b0/package.json +0 -3
- package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +0 -4505
- package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +0 -9731
- package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +0 -347
package/dist/cjs-legacy/hash.cjs
CHANGED
|
@@ -186,18 +186,11 @@ var _IterableEntryBase = class _IterableEntryBase {
|
|
|
186
186
|
__name(_IterableEntryBase, "IterableEntryBase");
|
|
187
187
|
var IterableEntryBase = _IterableEntryBase;
|
|
188
188
|
|
|
189
|
-
// src/utils/utils.ts
|
|
190
|
-
var rangeCheck = /* @__PURE__ */ __name((index, min, max, message) => {
|
|
191
|
-
if (index < min || index > max) {
|
|
192
|
-
throw new RangeError(message != null ? message : `Index ${index} is out of range [${min}, ${max}].`);
|
|
193
|
-
}
|
|
194
|
-
}, "rangeCheck");
|
|
195
|
-
var isWeakKey = /* @__PURE__ */ __name((input) => {
|
|
196
|
-
const inputType = typeof input;
|
|
197
|
-
return inputType === "object" && input !== null || inputType === "function";
|
|
198
|
-
}, "isWeakKey");
|
|
199
|
-
|
|
200
189
|
// src/common/error.ts
|
|
190
|
+
function raise(ErrorClass, message) {
|
|
191
|
+
throw new ErrorClass(message);
|
|
192
|
+
}
|
|
193
|
+
__name(raise, "raise");
|
|
201
194
|
var ERR = {
|
|
202
195
|
// Range / index
|
|
203
196
|
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
@@ -219,9 +212,22 @@ var ERR = {
|
|
|
219
212
|
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
220
213
|
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
221
214
|
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
222
|
-
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
|
|
215
|
+
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
|
|
216
|
+
// Order statistic
|
|
217
|
+
orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
|
|
223
218
|
};
|
|
224
219
|
|
|
220
|
+
// src/utils/utils.ts
|
|
221
|
+
var rangeCheck = /* @__PURE__ */ __name((index, min, max, message) => {
|
|
222
|
+
if (index < min || index > max) {
|
|
223
|
+
throw new RangeError(message != null ? message : `Index ${index} is out of range [${min}, ${max}].`);
|
|
224
|
+
}
|
|
225
|
+
}, "rangeCheck");
|
|
226
|
+
var isWeakKey = /* @__PURE__ */ __name((input) => {
|
|
227
|
+
const inputType = typeof input;
|
|
228
|
+
return inputType === "object" && input !== null || inputType === "function";
|
|
229
|
+
}, "isWeakKey");
|
|
230
|
+
|
|
225
231
|
// src/data-structures/hash/hash-map.ts
|
|
226
232
|
var _HashMap = class _HashMap extends IterableEntryBase {
|
|
227
233
|
/**
|
|
@@ -309,6 +315,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
309
315
|
|
|
310
316
|
|
|
311
317
|
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
312
326
|
|
|
313
327
|
|
|
314
328
|
|
|
@@ -350,6 +364,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
350
364
|
|
|
351
365
|
|
|
352
366
|
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
353
375
|
|
|
354
376
|
|
|
355
377
|
|
|
@@ -429,6 +451,22 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
429
451
|
|
|
430
452
|
|
|
431
453
|
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
|
|
432
470
|
|
|
433
471
|
|
|
434
472
|
|
|
@@ -474,7 +512,7 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
474
512
|
if (this.store[strKey] === void 0) this._size++;
|
|
475
513
|
this._store[strKey] = { key, value };
|
|
476
514
|
}
|
|
477
|
-
return
|
|
515
|
+
return this;
|
|
478
516
|
}
|
|
479
517
|
/**
|
|
480
518
|
* Insert many entries from an iterable.
|
|
@@ -501,6 +539,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
501
539
|
|
|
502
540
|
|
|
503
541
|
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
|
|
504
550
|
|
|
505
551
|
|
|
506
552
|
|
|
@@ -522,7 +568,11 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
522
568
|
let key, value;
|
|
523
569
|
if (this.isEntry(rawEle)) [key, value] = rawEle;
|
|
524
570
|
else if (this._toEntryFn) [key, value] = this._toEntryFn(rawEle);
|
|
525
|
-
if (key !== void 0 && value !== void 0)
|
|
571
|
+
if (key !== void 0 && value !== void 0) {
|
|
572
|
+
const sizeBefore = this._size;
|
|
573
|
+
this.set(key, value);
|
|
574
|
+
results.push(sizeBefore < this._size);
|
|
575
|
+
}
|
|
526
576
|
}
|
|
527
577
|
return results;
|
|
528
578
|
}
|
|
@@ -553,6 +603,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
553
603
|
|
|
554
604
|
|
|
555
605
|
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
|
|
556
614
|
|
|
557
615
|
|
|
558
616
|
|
|
@@ -617,6 +675,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
617
675
|
|
|
618
676
|
|
|
619
677
|
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
620
686
|
|
|
621
687
|
|
|
622
688
|
|
|
@@ -665,6 +731,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
665
731
|
|
|
666
732
|
|
|
667
733
|
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
668
742
|
|
|
669
743
|
|
|
670
744
|
|
|
@@ -731,6 +805,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
731
805
|
|
|
732
806
|
|
|
733
807
|
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
|
|
734
816
|
|
|
735
817
|
|
|
736
818
|
|
|
@@ -780,6 +862,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
780
862
|
|
|
781
863
|
|
|
782
864
|
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
|
|
783
873
|
|
|
784
874
|
|
|
785
875
|
|
|
@@ -831,6 +921,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
831
921
|
|
|
832
922
|
|
|
833
923
|
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
|
|
834
932
|
|
|
835
933
|
|
|
836
934
|
|
|
@@ -940,9 +1038,7 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
|
|
|
940
1038
|
if (this.isEntry(rawElement)) {
|
|
941
1039
|
return rawElement;
|
|
942
1040
|
}
|
|
943
|
-
|
|
944
|
-
ERR.invalidArgument("If elements do not adhere to [key, value], provide options.toEntryFn to transform raw records.", "HashMap")
|
|
945
|
-
);
|
|
1041
|
+
raise(TypeError, ERR.invalidArgument("If elements do not adhere to [key, value], provide options.toEntryFn to transform raw records.", "HashMap"));
|
|
946
1042
|
}, "_toEntryFn"));
|
|
947
1043
|
__publicField(this, "_size", 0);
|
|
948
1044
|
this._sentinel = {};
|
|
@@ -1046,7 +1142,7 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
|
|
|
1046
1142
|
* @remarks Time O(1), Space O(1)
|
|
1047
1143
|
* @param key - Key.
|
|
1048
1144
|
* @param [value] - Value.
|
|
1049
|
-
* @returns
|
|
1145
|
+
* @returns This map (for chaining).
|
|
1050
1146
|
*/
|
|
1051
1147
|
set(key, value) {
|
|
1052
1148
|
let node;
|
|
@@ -1081,7 +1177,7 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
|
|
|
1081
1177
|
this._sentinel.prev = node;
|
|
1082
1178
|
this._size++;
|
|
1083
1179
|
}
|
|
1084
|
-
return
|
|
1180
|
+
return this;
|
|
1085
1181
|
}
|
|
1086
1182
|
setMany(entryOrRawElements) {
|
|
1087
1183
|
const results = [];
|
|
@@ -1089,7 +1185,11 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
|
|
|
1089
1185
|
let key, value;
|
|
1090
1186
|
if (this.isEntry(rawEle)) [key, value] = rawEle;
|
|
1091
1187
|
else if (this._toEntryFn) [key, value] = this._toEntryFn(rawEle);
|
|
1092
|
-
if (key !== void 0 && value !== void 0)
|
|
1188
|
+
if (key !== void 0 && value !== void 0) {
|
|
1189
|
+
const sizeBefore = this._size;
|
|
1190
|
+
this.set(key, value);
|
|
1191
|
+
results.push(sizeBefore < this._size);
|
|
1192
|
+
}
|
|
1093
1193
|
}
|
|
1094
1194
|
return results;
|
|
1095
1195
|
}
|
|
@@ -1167,13 +1267,16 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
|
|
|
1167
1267
|
* Delete the entry at a given index.
|
|
1168
1268
|
* @remarks Time O(N), Space O(1)
|
|
1169
1269
|
* @param index - Zero-based index.
|
|
1170
|
-
* @returns
|
|
1270
|
+
* @returns The removed entry [key, value].
|
|
1271
|
+
* @throws {RangeError} If index is out of bounds.
|
|
1171
1272
|
*/
|
|
1172
1273
|
deleteAt(index) {
|
|
1173
1274
|
rangeCheck(index, 0, this._size - 1);
|
|
1174
1275
|
let node = this.head;
|
|
1175
1276
|
while (index--) node = node.next;
|
|
1176
|
-
|
|
1277
|
+
const entry = [node.key, node.value];
|
|
1278
|
+
this._deleteNode(node);
|
|
1279
|
+
return entry;
|
|
1177
1280
|
}
|
|
1178
1281
|
isEmpty() {
|
|
1179
1282
|
return this._size === 0;
|