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/esm-legacy/hash.mjs
CHANGED
|
@@ -184,18 +184,11 @@ var _IterableEntryBase = class _IterableEntryBase {
|
|
|
184
184
|
__name(_IterableEntryBase, "IterableEntryBase");
|
|
185
185
|
var IterableEntryBase = _IterableEntryBase;
|
|
186
186
|
|
|
187
|
-
// src/utils/utils.ts
|
|
188
|
-
var rangeCheck = /* @__PURE__ */ __name((index, min, max, message) => {
|
|
189
|
-
if (index < min || index > max) {
|
|
190
|
-
throw new RangeError(message != null ? message : `Index ${index} is out of range [${min}, ${max}].`);
|
|
191
|
-
}
|
|
192
|
-
}, "rangeCheck");
|
|
193
|
-
var isWeakKey = /* @__PURE__ */ __name((input) => {
|
|
194
|
-
const inputType = typeof input;
|
|
195
|
-
return inputType === "object" && input !== null || inputType === "function";
|
|
196
|
-
}, "isWeakKey");
|
|
197
|
-
|
|
198
187
|
// src/common/error.ts
|
|
188
|
+
function raise(ErrorClass, message) {
|
|
189
|
+
throw new ErrorClass(message);
|
|
190
|
+
}
|
|
191
|
+
__name(raise, "raise");
|
|
199
192
|
var ERR = {
|
|
200
193
|
// Range / index
|
|
201
194
|
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
@@ -217,9 +210,22 @@ var ERR = {
|
|
|
217
210
|
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
218
211
|
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
219
212
|
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
220
|
-
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
|
|
213
|
+
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
|
|
214
|
+
// Order statistic
|
|
215
|
+
orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
|
|
221
216
|
};
|
|
222
217
|
|
|
218
|
+
// src/utils/utils.ts
|
|
219
|
+
var rangeCheck = /* @__PURE__ */ __name((index, min, max, message) => {
|
|
220
|
+
if (index < min || index > max) {
|
|
221
|
+
throw new RangeError(message != null ? message : `Index ${index} is out of range [${min}, ${max}].`);
|
|
222
|
+
}
|
|
223
|
+
}, "rangeCheck");
|
|
224
|
+
var isWeakKey = /* @__PURE__ */ __name((input) => {
|
|
225
|
+
const inputType = typeof input;
|
|
226
|
+
return inputType === "object" && input !== null || inputType === "function";
|
|
227
|
+
}, "isWeakKey");
|
|
228
|
+
|
|
223
229
|
// src/data-structures/hash/hash-map.ts
|
|
224
230
|
var _HashMap = class _HashMap extends IterableEntryBase {
|
|
225
231
|
/**
|
|
@@ -307,6 +313,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
307
313
|
|
|
308
314
|
|
|
309
315
|
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
310
324
|
|
|
311
325
|
|
|
312
326
|
|
|
@@ -348,6 +362,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
348
362
|
|
|
349
363
|
|
|
350
364
|
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
351
373
|
|
|
352
374
|
|
|
353
375
|
|
|
@@ -427,6 +449,22 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
427
449
|
|
|
428
450
|
|
|
429
451
|
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
430
468
|
|
|
431
469
|
|
|
432
470
|
|
|
@@ -472,7 +510,7 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
472
510
|
if (this.store[strKey] === void 0) this._size++;
|
|
473
511
|
this._store[strKey] = { key, value };
|
|
474
512
|
}
|
|
475
|
-
return
|
|
513
|
+
return this;
|
|
476
514
|
}
|
|
477
515
|
/**
|
|
478
516
|
* Insert many entries from an iterable.
|
|
@@ -499,6 +537,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
499
537
|
|
|
500
538
|
|
|
501
539
|
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
502
548
|
|
|
503
549
|
|
|
504
550
|
|
|
@@ -520,7 +566,11 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
520
566
|
let key, value;
|
|
521
567
|
if (this.isEntry(rawEle)) [key, value] = rawEle;
|
|
522
568
|
else if (this._toEntryFn) [key, value] = this._toEntryFn(rawEle);
|
|
523
|
-
if (key !== void 0 && value !== void 0)
|
|
569
|
+
if (key !== void 0 && value !== void 0) {
|
|
570
|
+
const sizeBefore = this._size;
|
|
571
|
+
this.set(key, value);
|
|
572
|
+
results.push(sizeBefore < this._size);
|
|
573
|
+
}
|
|
524
574
|
}
|
|
525
575
|
return results;
|
|
526
576
|
}
|
|
@@ -551,6 +601,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
551
601
|
|
|
552
602
|
|
|
553
603
|
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
554
612
|
|
|
555
613
|
|
|
556
614
|
|
|
@@ -615,6 +673,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
615
673
|
|
|
616
674
|
|
|
617
675
|
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
618
684
|
|
|
619
685
|
|
|
620
686
|
|
|
@@ -663,6 +729,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
663
729
|
|
|
664
730
|
|
|
665
731
|
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
666
740
|
|
|
667
741
|
|
|
668
742
|
|
|
@@ -729,6 +803,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
729
803
|
|
|
730
804
|
|
|
731
805
|
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
|
|
732
814
|
|
|
733
815
|
|
|
734
816
|
|
|
@@ -778,6 +860,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
778
860
|
|
|
779
861
|
|
|
780
862
|
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
|
|
781
871
|
|
|
782
872
|
|
|
783
873
|
|
|
@@ -829,6 +919,14 @@ var _HashMap = class _HashMap extends IterableEntryBase {
|
|
|
829
919
|
|
|
830
920
|
|
|
831
921
|
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
|
|
832
930
|
|
|
833
931
|
|
|
834
932
|
|
|
@@ -938,9 +1036,7 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
|
|
|
938
1036
|
if (this.isEntry(rawElement)) {
|
|
939
1037
|
return rawElement;
|
|
940
1038
|
}
|
|
941
|
-
|
|
942
|
-
ERR.invalidArgument("If elements do not adhere to [key, value], provide options.toEntryFn to transform raw records.", "HashMap")
|
|
943
|
-
);
|
|
1039
|
+
raise(TypeError, ERR.invalidArgument("If elements do not adhere to [key, value], provide options.toEntryFn to transform raw records.", "HashMap"));
|
|
944
1040
|
}, "_toEntryFn"));
|
|
945
1041
|
__publicField(this, "_size", 0);
|
|
946
1042
|
this._sentinel = {};
|
|
@@ -1044,7 +1140,7 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
|
|
|
1044
1140
|
* @remarks Time O(1), Space O(1)
|
|
1045
1141
|
* @param key - Key.
|
|
1046
1142
|
* @param [value] - Value.
|
|
1047
|
-
* @returns
|
|
1143
|
+
* @returns This map (for chaining).
|
|
1048
1144
|
*/
|
|
1049
1145
|
set(key, value) {
|
|
1050
1146
|
let node;
|
|
@@ -1079,7 +1175,7 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
|
|
|
1079
1175
|
this._sentinel.prev = node;
|
|
1080
1176
|
this._size++;
|
|
1081
1177
|
}
|
|
1082
|
-
return
|
|
1178
|
+
return this;
|
|
1083
1179
|
}
|
|
1084
1180
|
setMany(entryOrRawElements) {
|
|
1085
1181
|
const results = [];
|
|
@@ -1087,7 +1183,11 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
|
|
|
1087
1183
|
let key, value;
|
|
1088
1184
|
if (this.isEntry(rawEle)) [key, value] = rawEle;
|
|
1089
1185
|
else if (this._toEntryFn) [key, value] = this._toEntryFn(rawEle);
|
|
1090
|
-
if (key !== void 0 && value !== void 0)
|
|
1186
|
+
if (key !== void 0 && value !== void 0) {
|
|
1187
|
+
const sizeBefore = this._size;
|
|
1188
|
+
this.set(key, value);
|
|
1189
|
+
results.push(sizeBefore < this._size);
|
|
1190
|
+
}
|
|
1091
1191
|
}
|
|
1092
1192
|
return results;
|
|
1093
1193
|
}
|
|
@@ -1165,13 +1265,16 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
|
|
|
1165
1265
|
* Delete the entry at a given index.
|
|
1166
1266
|
* @remarks Time O(N), Space O(1)
|
|
1167
1267
|
* @param index - Zero-based index.
|
|
1168
|
-
* @returns
|
|
1268
|
+
* @returns The removed entry [key, value].
|
|
1269
|
+
* @throws {RangeError} If index is out of bounds.
|
|
1169
1270
|
*/
|
|
1170
1271
|
deleteAt(index) {
|
|
1171
1272
|
rangeCheck(index, 0, this._size - 1);
|
|
1172
1273
|
let node = this.head;
|
|
1173
1274
|
while (index--) node = node.next;
|
|
1174
|
-
|
|
1275
|
+
const entry = [node.key, node.value];
|
|
1276
|
+
this._deleteNode(node);
|
|
1277
|
+
return entry;
|
|
1175
1278
|
}
|
|
1176
1279
|
isEmpty() {
|
|
1177
1280
|
return this._size === 0;
|