priority-queue-typed 2.5.3 → 2.6.0
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/dist/cjs/index.cjs +71 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +71 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +71 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +71 -0
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
- package/dist/types/data-structures/base/linear-base.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +75 -0
- package/dist/types/data-structures/binary-tree/bst.d.ts +72 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +375 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +389 -0
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +330 -0
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +438 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
- package/dist/types/data-structures/heap/heap.d.ts +42 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
- package/dist/types/data-structures/queue/deque.d.ts +90 -1
- package/dist/types/data-structures/queue/queue.d.ts +36 -0
- package/dist/types/data-structures/stack/stack.d.ts +30 -0
- package/dist/types/data-structures/trie/trie.d.ts +36 -0
- package/dist/umd/priority-queue-typed.js +71 -0
- package/dist/umd/priority-queue-typed.js.map +1 -1
- package/dist/umd/priority-queue-typed.min.js +1 -1
- package/dist/umd/priority-queue-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +32 -0
- package/src/data-structures/base/linear-base.ts +11 -0
- package/src/data-structures/binary-tree/avl-tree.ts +36 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +42 -0
- package/src/data-structures/binary-tree/binary-tree.ts +75 -0
- package/src/data-structures/binary-tree/bst.ts +72 -0
- package/src/data-structures/binary-tree/red-black-tree.ts +57 -0
- package/src/data-structures/binary-tree/segment-tree.ts +18 -0
- package/src/data-structures/binary-tree/tree-map.ts +375 -0
- package/src/data-structures/binary-tree/tree-multi-map.ts +392 -0
- package/src/data-structures/binary-tree/tree-multi-set.ts +336 -0
- package/src/data-structures/binary-tree/tree-set.ts +492 -0
- 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 +33 -0
- package/src/data-structures/heap/heap.ts +42 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +90 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +54 -0
- package/src/data-structures/matrix/matrix.ts +24 -0
- package/src/data-structures/queue/deque.ts +103 -1
- 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 +36 -0
|
@@ -208,6 +208,35 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
208
208
|
for (const ele of this) if (ele === element) return true;
|
|
209
209
|
return false;
|
|
210
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Check whether a value exists (Array-compatible alias for `has`).
|
|
213
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
214
|
+
* @param element - Element to search for (uses `===`).
|
|
215
|
+
* @returns `true` if found.
|
|
216
|
+
*/
|
|
217
|
+
includes(element) {
|
|
218
|
+
return this.has(element);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
222
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
223
|
+
*/
|
|
224
|
+
*entries() {
|
|
225
|
+
let index = 0;
|
|
226
|
+
for (const value of this) {
|
|
227
|
+
yield [index++, value];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Return an iterator of numeric indices (Array-compatible).
|
|
232
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
233
|
+
*/
|
|
234
|
+
*keys() {
|
|
235
|
+
let index = 0;
|
|
236
|
+
for (const _ of this) {
|
|
237
|
+
yield index++;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
211
240
|
/**
|
|
212
241
|
* Reduces all elements to a single accumulated value.
|
|
213
242
|
*
|
|
@@ -356,6 +385,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
356
385
|
|
|
357
386
|
|
|
358
387
|
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
359
391
|
|
|
360
392
|
|
|
361
393
|
|
|
@@ -447,6 +479,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
447
479
|
|
|
448
480
|
|
|
449
481
|
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
450
485
|
|
|
451
486
|
|
|
452
487
|
|
|
@@ -508,6 +543,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
508
543
|
|
|
509
544
|
|
|
510
545
|
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
511
549
|
|
|
512
550
|
|
|
513
551
|
|
|
@@ -602,6 +640,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
602
640
|
*/
|
|
603
641
|
/**
|
|
604
642
|
* @deprecated Use `pop` instead. Will be removed in a future major version.
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
605
646
|
* @example
|
|
606
647
|
* // Heap with custom comparator (MaxHeap behavior)
|
|
607
648
|
* interface Task {
|
|
@@ -685,6 +726,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
685
726
|
|
|
686
727
|
|
|
687
728
|
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
|
|
688
732
|
|
|
689
733
|
|
|
690
734
|
|
|
@@ -789,6 +833,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
789
833
|
|
|
790
834
|
|
|
791
835
|
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
792
839
|
|
|
793
840
|
|
|
794
841
|
|
|
@@ -840,6 +887,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
840
887
|
|
|
841
888
|
|
|
842
889
|
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
843
893
|
|
|
844
894
|
|
|
845
895
|
|
|
@@ -884,6 +934,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
884
934
|
|
|
885
935
|
|
|
886
936
|
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
|
|
887
940
|
|
|
888
941
|
|
|
889
942
|
|
|
@@ -935,6 +988,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
935
988
|
|
|
936
989
|
|
|
937
990
|
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
|
|
938
994
|
|
|
939
995
|
|
|
940
996
|
|
|
@@ -1038,6 +1094,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1038
1094
|
|
|
1039
1095
|
|
|
1040
1096
|
|
|
1097
|
+
|
|
1098
|
+
|
|
1099
|
+
|
|
1041
1100
|
|
|
1042
1101
|
|
|
1043
1102
|
|
|
@@ -1122,6 +1181,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1122
1181
|
|
|
1123
1182
|
|
|
1124
1183
|
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
|
|
1125
1187
|
|
|
1126
1188
|
|
|
1127
1189
|
|
|
@@ -1179,6 +1241,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1179
1241
|
|
|
1180
1242
|
|
|
1181
1243
|
|
|
1244
|
+
|
|
1245
|
+
|
|
1246
|
+
|
|
1182
1247
|
|
|
1183
1248
|
|
|
1184
1249
|
|
|
@@ -1235,6 +1300,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1235
1300
|
|
|
1236
1301
|
|
|
1237
1302
|
|
|
1303
|
+
|
|
1304
|
+
|
|
1305
|
+
|
|
1238
1306
|
|
|
1239
1307
|
|
|
1240
1308
|
|
|
@@ -1298,6 +1366,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1298
1366
|
|
|
1299
1367
|
|
|
1300
1368
|
|
|
1369
|
+
|
|
1370
|
+
|
|
1371
|
+
|
|
1301
1372
|
|
|
1302
1373
|
|
|
1303
1374
|
|