data-structure-typed 2.5.1 → 2.5.2
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 +3 -1
- package/README.md +75 -17
- package/dist/cjs/binary-tree.cjs +2723 -139
- package/dist/cjs/graph.cjs +192 -6
- package/dist/cjs/hash.cjs +63 -15
- package/dist/cjs/heap.cjs +93 -31
- package/dist/cjs/index.cjs +3514 -379
- package/dist/cjs/linked-list.cjs +237 -31
- package/dist/cjs/matrix.cjs +47 -9
- package/dist/cjs/priority-queue.cjs +92 -30
- package/dist/cjs/queue.cjs +176 -2
- package/dist/cjs/stack.cjs +48 -2
- package/dist/cjs/trie.cjs +78 -28
- package/dist/cjs-legacy/binary-tree.cjs +2725 -136
- package/dist/cjs-legacy/graph.cjs +192 -6
- package/dist/cjs-legacy/hash.cjs +63 -15
- package/dist/cjs-legacy/heap.cjs +93 -31
- package/dist/cjs-legacy/index.cjs +3389 -249
- package/dist/cjs-legacy/linked-list.cjs +237 -31
- package/dist/cjs-legacy/matrix.cjs +47 -9
- package/dist/cjs-legacy/priority-queue.cjs +92 -30
- package/dist/cjs-legacy/queue.cjs +176 -2
- package/dist/cjs-legacy/stack.cjs +48 -2
- package/dist/cjs-legacy/trie.cjs +78 -28
- package/dist/esm/binary-tree.mjs +2723 -139
- package/dist/esm/graph.mjs +192 -6
- package/dist/esm/hash.mjs +63 -15
- package/dist/esm/heap.mjs +93 -31
- package/dist/esm/index.mjs +3514 -380
- package/dist/esm/linked-list.mjs +237 -31
- package/dist/esm/matrix.mjs +47 -9
- package/dist/esm/priority-queue.mjs +92 -30
- package/dist/esm/queue.mjs +176 -2
- package/dist/esm/stack.mjs +48 -2
- package/dist/esm/trie.mjs +78 -28
- package/dist/esm-legacy/binary-tree.mjs +2725 -136
- package/dist/esm-legacy/graph.mjs +192 -6
- package/dist/esm-legacy/hash.mjs +63 -15
- package/dist/esm-legacy/heap.mjs +93 -31
- package/dist/esm-legacy/index.mjs +3389 -250
- package/dist/esm-legacy/linked-list.mjs +237 -31
- package/dist/esm-legacy/matrix.mjs +47 -9
- package/dist/esm-legacy/priority-queue.mjs +92 -30
- package/dist/esm-legacy/queue.mjs +176 -2
- package/dist/esm-legacy/stack.mjs +48 -2
- package/dist/esm-legacy/trie.mjs +78 -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 +48 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +56 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +102 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +195 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +76 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +528 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +531 -6
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +435 -6
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +505 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +40 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +36 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +44 -0
- package/dist/types/data-structures/heap/heap.d.ts +56 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +68 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +60 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +72 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +32 -0
- package/dist/types/data-structures/queue/deque.d.ts +60 -0
- package/dist/types/data-structures/queue/queue.d.ts +48 -0
- package/dist/types/data-structures/stack/stack.d.ts +40 -0
- package/dist/types/data-structures/trie/trie.d.ts +48 -0
- 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 +3404 -265
- package/dist/umd/data-structure-typed.min.js +5 -5
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +650 -136
- 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 +591 -129
- 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 +107 -107
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +82 -82
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +82 -82
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +74 -74
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +47 -47
- package/docs-site-docusaurus/docs/api/classes/Heap.md +45 -45
- 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 +49 -49
- 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 +45 -45
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +44 -44
- package/docs-site-docusaurus/docs/api/classes/Queue.md +60 -60
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +660 -146
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +78 -78
- 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 +39 -39
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +165 -33
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +162 -46
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +161 -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 +2 -0
- package/docs-site-docusaurus/docs/guide/concepts.md +32 -1
- package/docs-site-docusaurus/docs/guide/faq.md +180 -0
- package/docs-site-docusaurus/docs/guide/guides.md +40 -54
- package/docs-site-docusaurus/docs/guide/installation.md +2 -0
- package/docs-site-docusaurus/docs/guide/integrations.md +2 -0
- package/docs-site-docusaurus/docs/guide/overview.md +7 -0
- 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 +51 -2
- package/docs-site-docusaurus/static/llms.txt +37 -0
- package/llms.txt +37 -0
- package/package.json +64 -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 +47 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +46 -4
- package/src/data-structures/binary-tree/binary-tree.ts +79 -4
- package/src/data-structures/binary-tree/bst.ts +441 -6
- package/src/data-structures/binary-tree/red-black-tree.ts +73 -0
- package/src/data-structures/binary-tree/segment-tree.ts +18 -0
- package/src/data-structures/binary-tree/tree-map.ts +434 -9
- package/src/data-structures/binary-tree/tree-multi-map.ts +426 -5
- package/src/data-structures/binary-tree/tree-multi-set.ts +350 -6
- package/src/data-structures/binary-tree/tree-set.ts +410 -8
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +30 -0
- package/src/data-structures/graph/undirected-graph.ts +27 -0
- package/src/data-structures/hash/hash-map.ts +35 -4
- package/src/data-structures/heap/heap.ts +46 -4
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +51 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +59 -5
- package/src/data-structures/matrix/matrix.ts +33 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +45 -0
- package/src/data-structures/queue/queue.ts +36 -0
- package/src/data-structures/stack/stack.ts +30 -0
- package/src/data-structures/trie/trie.ts +38 -2
- 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/dist/cjs-legacy/heap.cjs
CHANGED
|
@@ -5,6 +5,37 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
5
5
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
6
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
7
|
|
|
8
|
+
// src/common/error.ts
|
|
9
|
+
function raise(ErrorClass, message) {
|
|
10
|
+
throw new ErrorClass(message);
|
|
11
|
+
}
|
|
12
|
+
__name(raise, "raise");
|
|
13
|
+
var ERR = {
|
|
14
|
+
// Range / index
|
|
15
|
+
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
16
|
+
invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
|
|
17
|
+
// Type / argument
|
|
18
|
+
invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
|
|
19
|
+
comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
|
|
20
|
+
invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
|
|
21
|
+
notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
|
|
22
|
+
invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
|
|
23
|
+
invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
|
|
24
|
+
invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
|
|
25
|
+
reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
|
|
26
|
+
callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
|
|
27
|
+
// State / operation
|
|
28
|
+
invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
|
|
29
|
+
// Matrix
|
|
30
|
+
matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
|
|
31
|
+
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
32
|
+
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
33
|
+
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
34
|
+
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch"),
|
|
35
|
+
// Order statistic
|
|
36
|
+
orderStatisticNotEnabled: /* @__PURE__ */ __name((method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`, "orderStatisticNotEnabled")
|
|
37
|
+
};
|
|
38
|
+
|
|
8
39
|
// src/data-structures/base/iterable-element-base.ts
|
|
9
40
|
var _IterableElementBase = class _IterableElementBase {
|
|
10
41
|
/**
|
|
@@ -27,7 +58,7 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
27
58
|
if (options) {
|
|
28
59
|
const { toElementFn } = options;
|
|
29
60
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
30
|
-
else if (toElementFn)
|
|
61
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
31
62
|
}
|
|
32
63
|
}
|
|
33
64
|
/**
|
|
@@ -183,7 +214,7 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
183
214
|
acc = initialValue;
|
|
184
215
|
} else {
|
|
185
216
|
const first = iter.next();
|
|
186
|
-
if (first.done)
|
|
217
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
187
218
|
acc = first.value;
|
|
188
219
|
index = 1;
|
|
189
220
|
}
|
|
@@ -227,31 +258,6 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
227
258
|
__name(_IterableElementBase, "IterableElementBase");
|
|
228
259
|
var IterableElementBase = _IterableElementBase;
|
|
229
260
|
|
|
230
|
-
// src/common/error.ts
|
|
231
|
-
var ERR = {
|
|
232
|
-
// Range / index
|
|
233
|
-
indexOutOfRange: /* @__PURE__ */ __name((index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`, "indexOutOfRange"),
|
|
234
|
-
invalidIndex: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`, "invalidIndex"),
|
|
235
|
-
// Type / argument
|
|
236
|
-
invalidArgument: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidArgument"),
|
|
237
|
-
comparatorRequired: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`, "comparatorRequired"),
|
|
238
|
-
invalidKey: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidKey"),
|
|
239
|
-
notAFunction: /* @__PURE__ */ __name((name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`, "notAFunction"),
|
|
240
|
-
invalidEntry: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`, "invalidEntry"),
|
|
241
|
-
invalidNaN: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`, "invalidNaN"),
|
|
242
|
-
invalidDate: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`, "invalidDate"),
|
|
243
|
-
reduceEmpty: /* @__PURE__ */ __name((ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`, "reduceEmpty"),
|
|
244
|
-
callbackReturnType: /* @__PURE__ */ __name((expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`, "callbackReturnType"),
|
|
245
|
-
// State / operation
|
|
246
|
-
invalidOperation: /* @__PURE__ */ __name((reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`, "invalidOperation"),
|
|
247
|
-
// Matrix
|
|
248
|
-
matrixDimensionMismatch: /* @__PURE__ */ __name((op) => `Matrix: Dimensions must be compatible for ${op}.`, "matrixDimensionMismatch"),
|
|
249
|
-
matrixSingular: /* @__PURE__ */ __name(() => "Matrix: Singular matrix, inverse does not exist.", "matrixSingular"),
|
|
250
|
-
matrixNotSquare: /* @__PURE__ */ __name(() => "Matrix: Must be square for inversion.", "matrixNotSquare"),
|
|
251
|
-
matrixNotRectangular: /* @__PURE__ */ __name(() => "Matrix: Must be rectangular for transposition.", "matrixNotRectangular"),
|
|
252
|
-
matrixRowMismatch: /* @__PURE__ */ __name((expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`, "matrixRowMismatch")
|
|
253
|
-
};
|
|
254
|
-
|
|
255
261
|
// src/data-structures/heap/heap.ts
|
|
256
262
|
var _Heap = class _Heap extends IterableElementBase {
|
|
257
263
|
/**
|
|
@@ -267,7 +273,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
267
273
|
__publicField(this, "_elements", []);
|
|
268
274
|
__publicField(this, "_DEFAULT_COMPARATOR", /* @__PURE__ */ __name((a, b) => {
|
|
269
275
|
if (typeof a === "object" || typeof b === "object") {
|
|
270
|
-
|
|
276
|
+
raise(TypeError, ERR.comparatorRequired("Heap"));
|
|
271
277
|
}
|
|
272
278
|
if (a > b) return 1;
|
|
273
279
|
if (a < b) return -1;
|
|
@@ -318,6 +324,10 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
318
324
|
|
|
319
325
|
|
|
320
326
|
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
321
331
|
|
|
322
332
|
|
|
323
333
|
|
|
@@ -401,6 +411,10 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
401
411
|
|
|
402
412
|
|
|
403
413
|
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
404
418
|
|
|
405
419
|
|
|
406
420
|
|
|
@@ -454,6 +468,10 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
454
468
|
|
|
455
469
|
|
|
456
470
|
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
457
475
|
|
|
458
476
|
|
|
459
477
|
|
|
@@ -509,6 +527,10 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
509
527
|
|
|
510
528
|
|
|
511
529
|
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
512
534
|
|
|
513
535
|
|
|
514
536
|
|
|
@@ -580,6 +602,10 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
580
602
|
|
|
581
603
|
|
|
582
604
|
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
583
609
|
|
|
584
610
|
|
|
585
611
|
|
|
@@ -676,6 +702,10 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
676
702
|
|
|
677
703
|
|
|
678
704
|
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
|
|
679
709
|
|
|
680
710
|
|
|
681
711
|
|
|
@@ -719,6 +749,10 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
719
749
|
|
|
720
750
|
|
|
721
751
|
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
722
756
|
|
|
723
757
|
|
|
724
758
|
|
|
@@ -765,6 +799,10 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
765
799
|
|
|
766
800
|
|
|
767
801
|
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
|
|
768
806
|
|
|
769
807
|
|
|
770
808
|
|
|
@@ -808,6 +846,10 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
808
846
|
|
|
809
847
|
|
|
810
848
|
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
|
|
811
853
|
|
|
812
854
|
|
|
813
855
|
|
|
@@ -897,6 +939,10 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
897
939
|
|
|
898
940
|
|
|
899
941
|
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
|
|
900
946
|
|
|
901
947
|
|
|
902
948
|
|
|
@@ -973,6 +1019,10 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
973
1019
|
|
|
974
1020
|
|
|
975
1021
|
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
|
|
976
1026
|
|
|
977
1027
|
|
|
978
1028
|
|
|
@@ -1022,6 +1072,10 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1022
1072
|
|
|
1023
1073
|
|
|
1024
1074
|
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
|
|
1025
1079
|
|
|
1026
1080
|
|
|
1027
1081
|
|
|
@@ -1070,6 +1124,10 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1070
1124
|
|
|
1071
1125
|
|
|
1072
1126
|
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
|
|
1073
1131
|
|
|
1074
1132
|
|
|
1075
1133
|
|
|
@@ -1125,6 +1183,10 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1125
1183
|
|
|
1126
1184
|
|
|
1127
1185
|
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
|
|
1128
1190
|
|
|
1129
1191
|
|
|
1130
1192
|
|
|
@@ -1138,7 +1200,7 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1138
1200
|
*/
|
|
1139
1201
|
map(callback, options, thisArg) {
|
|
1140
1202
|
const { comparator, toElementFn, ...rest } = options != null ? options : {};
|
|
1141
|
-
if (!comparator)
|
|
1203
|
+
if (!comparator) raise(TypeError, ERR.comparatorRequired("Heap.map"));
|
|
1142
1204
|
const out = this._createLike([], { ...rest, comparator, toElementFn });
|
|
1143
1205
|
let i = 0;
|
|
1144
1206
|
for (const x of this) {
|
|
@@ -1270,7 +1332,7 @@ var _FibonacciHeap = class _FibonacciHeap {
|
|
|
1270
1332
|
__publicField(this, "_comparator");
|
|
1271
1333
|
this.clear();
|
|
1272
1334
|
this._comparator = comparator || this._defaultComparator;
|
|
1273
|
-
if (typeof this.comparator !== "function")
|
|
1335
|
+
if (typeof this.comparator !== "function") raise(TypeError, ERR.notAFunction("comparator", "FibonacciHeap"));
|
|
1274
1336
|
}
|
|
1275
1337
|
/**
|
|
1276
1338
|
* Get the circular root list head.
|
|
@@ -1481,7 +1543,7 @@ var _MaxHeap = class _MaxHeap extends Heap {
|
|
|
1481
1543
|
super(elements, {
|
|
1482
1544
|
comparator: /* @__PURE__ */ __name((a, b) => {
|
|
1483
1545
|
if (typeof a === "object" || typeof b === "object") {
|
|
1484
|
-
|
|
1546
|
+
raise(TypeError, ERR.comparatorRequired("MaxHeap"));
|
|
1485
1547
|
}
|
|
1486
1548
|
if (a < b) return 1;
|
|
1487
1549
|
if (a > b) return -1;
|