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
|
@@ -206,6 +206,35 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
206
206
|
for (const ele of this) if (ele === element) return true;
|
|
207
207
|
return false;
|
|
208
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Check whether a value exists (Array-compatible alias for `has`).
|
|
211
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
212
|
+
* @param element - Element to search for (uses `===`).
|
|
213
|
+
* @returns `true` if found.
|
|
214
|
+
*/
|
|
215
|
+
includes(element) {
|
|
216
|
+
return this.has(element);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
220
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
221
|
+
*/
|
|
222
|
+
*entries() {
|
|
223
|
+
let index = 0;
|
|
224
|
+
for (const value of this) {
|
|
225
|
+
yield [index++, value];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Return an iterator of numeric indices (Array-compatible).
|
|
230
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
231
|
+
*/
|
|
232
|
+
*keys() {
|
|
233
|
+
let index = 0;
|
|
234
|
+
for (const _ of this) {
|
|
235
|
+
yield index++;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
209
238
|
/**
|
|
210
239
|
* Reduces all elements to a single accumulated value.
|
|
211
240
|
*
|
|
@@ -354,6 +383,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
354
383
|
|
|
355
384
|
|
|
356
385
|
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
357
389
|
|
|
358
390
|
|
|
359
391
|
|
|
@@ -445,6 +477,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
445
477
|
|
|
446
478
|
|
|
447
479
|
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
448
483
|
|
|
449
484
|
|
|
450
485
|
|
|
@@ -506,6 +541,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
506
541
|
|
|
507
542
|
|
|
508
543
|
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
509
547
|
|
|
510
548
|
|
|
511
549
|
|
|
@@ -600,6 +638,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
600
638
|
*/
|
|
601
639
|
/**
|
|
602
640
|
* @deprecated Use `pop` instead. Will be removed in a future major version.
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
603
644
|
* @example
|
|
604
645
|
* // Heap with custom comparator (MaxHeap behavior)
|
|
605
646
|
* interface Task {
|
|
@@ -683,6 +724,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
683
724
|
|
|
684
725
|
|
|
685
726
|
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
|
|
686
730
|
|
|
687
731
|
|
|
688
732
|
|
|
@@ -787,6 +831,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
787
831
|
|
|
788
832
|
|
|
789
833
|
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
790
837
|
|
|
791
838
|
|
|
792
839
|
|
|
@@ -838,6 +885,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
838
885
|
|
|
839
886
|
|
|
840
887
|
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
841
891
|
|
|
842
892
|
|
|
843
893
|
|
|
@@ -882,6 +932,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
882
932
|
|
|
883
933
|
|
|
884
934
|
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
|
|
885
938
|
|
|
886
939
|
|
|
887
940
|
|
|
@@ -933,6 +986,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
933
986
|
|
|
934
987
|
|
|
935
988
|
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
|
|
936
992
|
|
|
937
993
|
|
|
938
994
|
|
|
@@ -1036,6 +1092,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1036
1092
|
|
|
1037
1093
|
|
|
1038
1094
|
|
|
1095
|
+
|
|
1096
|
+
|
|
1097
|
+
|
|
1039
1098
|
|
|
1040
1099
|
|
|
1041
1100
|
|
|
@@ -1120,6 +1179,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1120
1179
|
|
|
1121
1180
|
|
|
1122
1181
|
|
|
1182
|
+
|
|
1183
|
+
|
|
1184
|
+
|
|
1123
1185
|
|
|
1124
1186
|
|
|
1125
1187
|
|
|
@@ -1177,6 +1239,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1177
1239
|
|
|
1178
1240
|
|
|
1179
1241
|
|
|
1242
|
+
|
|
1243
|
+
|
|
1244
|
+
|
|
1180
1245
|
|
|
1181
1246
|
|
|
1182
1247
|
|
|
@@ -1233,6 +1298,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1233
1298
|
|
|
1234
1299
|
|
|
1235
1300
|
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
|
|
1236
1304
|
|
|
1237
1305
|
|
|
1238
1306
|
|
|
@@ -1296,6 +1364,9 @@ var _Heap = class _Heap extends IterableElementBase {
|
|
|
1296
1364
|
|
|
1297
1365
|
|
|
1298
1366
|
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
|
|
1299
1370
|
|
|
1300
1371
|
|
|
1301
1372
|
|