graph-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 +174 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +174 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +174 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +174 -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/graph-typed.js +174 -0
- package/dist/umd/graph-typed.js.map +1 -1
- package/dist/umd/graph-typed.min.js +1 -1
- package/dist/umd/graph-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
package/dist/cjs/index.cjs
CHANGED
|
@@ -413,6 +413,35 @@ var IterableElementBase = class {
|
|
|
413
413
|
for (const ele of this) if (ele === element) return true;
|
|
414
414
|
return false;
|
|
415
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* Check whether a value exists (Array-compatible alias for `has`).
|
|
418
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
419
|
+
* @param element - Element to search for (uses `===`).
|
|
420
|
+
* @returns `true` if found.
|
|
421
|
+
*/
|
|
422
|
+
includes(element) {
|
|
423
|
+
return this.has(element);
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
427
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
428
|
+
*/
|
|
429
|
+
*entries() {
|
|
430
|
+
let index = 0;
|
|
431
|
+
for (const value of this) {
|
|
432
|
+
yield [index++, value];
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Return an iterator of numeric indices (Array-compatible).
|
|
437
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
438
|
+
*/
|
|
439
|
+
*keys() {
|
|
440
|
+
let index = 0;
|
|
441
|
+
for (const _ of this) {
|
|
442
|
+
yield index++;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
416
445
|
/**
|
|
417
446
|
* Reduces all elements to a single accumulated value.
|
|
418
447
|
*
|
|
@@ -675,6 +704,16 @@ var LinearBase = class _LinearBase extends IterableElementBase {
|
|
|
675
704
|
}
|
|
676
705
|
return this;
|
|
677
706
|
}
|
|
707
|
+
/**
|
|
708
|
+
* Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
709
|
+
* @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
710
|
+
* @returns A new reversed instance.
|
|
711
|
+
*/
|
|
712
|
+
toReversed() {
|
|
713
|
+
const cloned = this.clone();
|
|
714
|
+
cloned.reverse();
|
|
715
|
+
return cloned;
|
|
716
|
+
}
|
|
678
717
|
};
|
|
679
718
|
|
|
680
719
|
// src/data-structures/heap/heap.ts
|
|
@@ -746,6 +785,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
746
785
|
|
|
747
786
|
|
|
748
787
|
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
|
|
749
791
|
|
|
750
792
|
|
|
751
793
|
|
|
@@ -836,6 +878,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
836
878
|
|
|
837
879
|
|
|
838
880
|
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
|
|
839
884
|
|
|
840
885
|
|
|
841
886
|
|
|
@@ -897,6 +942,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
897
942
|
|
|
898
943
|
|
|
899
944
|
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|
|
900
948
|
|
|
901
949
|
|
|
902
950
|
|
|
@@ -991,6 +1039,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
991
1039
|
*/
|
|
992
1040
|
/**
|
|
993
1041
|
* @deprecated Use `pop` instead. Will be removed in a future major version.
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
|
|
994
1045
|
* @example
|
|
995
1046
|
* // Heap with custom comparator (MaxHeap behavior)
|
|
996
1047
|
* interface Task {
|
|
@@ -1074,6 +1125,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1074
1125
|
|
|
1075
1126
|
|
|
1076
1127
|
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
|
|
1077
1131
|
|
|
1078
1132
|
|
|
1079
1133
|
|
|
@@ -1178,6 +1232,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1178
1232
|
|
|
1179
1233
|
|
|
1180
1234
|
|
|
1235
|
+
|
|
1236
|
+
|
|
1237
|
+
|
|
1181
1238
|
|
|
1182
1239
|
|
|
1183
1240
|
|
|
@@ -1229,6 +1286,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1229
1286
|
|
|
1230
1287
|
|
|
1231
1288
|
|
|
1289
|
+
|
|
1290
|
+
|
|
1291
|
+
|
|
1232
1292
|
|
|
1233
1293
|
|
|
1234
1294
|
|
|
@@ -1273,6 +1333,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1273
1333
|
|
|
1274
1334
|
|
|
1275
1335
|
|
|
1336
|
+
|
|
1337
|
+
|
|
1338
|
+
|
|
1276
1339
|
|
|
1277
1340
|
|
|
1278
1341
|
|
|
@@ -1324,6 +1387,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1324
1387
|
|
|
1325
1388
|
|
|
1326
1389
|
|
|
1390
|
+
|
|
1391
|
+
|
|
1392
|
+
|
|
1327
1393
|
|
|
1328
1394
|
|
|
1329
1395
|
|
|
@@ -1427,6 +1493,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1427
1493
|
|
|
1428
1494
|
|
|
1429
1495
|
|
|
1496
|
+
|
|
1497
|
+
|
|
1498
|
+
|
|
1430
1499
|
|
|
1431
1500
|
|
|
1432
1501
|
|
|
@@ -1511,6 +1580,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1511
1580
|
|
|
1512
1581
|
|
|
1513
1582
|
|
|
1583
|
+
|
|
1584
|
+
|
|
1585
|
+
|
|
1514
1586
|
|
|
1515
1587
|
|
|
1516
1588
|
|
|
@@ -1568,6 +1640,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1568
1640
|
|
|
1569
1641
|
|
|
1570
1642
|
|
|
1643
|
+
|
|
1644
|
+
|
|
1645
|
+
|
|
1571
1646
|
|
|
1572
1647
|
|
|
1573
1648
|
|
|
@@ -1624,6 +1699,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1624
1699
|
|
|
1625
1700
|
|
|
1626
1701
|
|
|
1702
|
+
|
|
1703
|
+
|
|
1704
|
+
|
|
1627
1705
|
|
|
1628
1706
|
|
|
1629
1707
|
|
|
@@ -1687,6 +1765,9 @@ var Heap = class _Heap extends IterableElementBase {
|
|
|
1687
1765
|
|
|
1688
1766
|
|
|
1689
1767
|
|
|
1768
|
+
|
|
1769
|
+
|
|
1770
|
+
|
|
1690
1771
|
|
|
1691
1772
|
|
|
1692
1773
|
|
|
@@ -1904,6 +1985,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1904
1985
|
|
|
1905
1986
|
|
|
1906
1987
|
|
|
1988
|
+
|
|
1989
|
+
|
|
1990
|
+
|
|
1907
1991
|
|
|
1908
1992
|
|
|
1909
1993
|
|
|
@@ -1958,6 +2042,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1958
2042
|
|
|
1959
2043
|
|
|
1960
2044
|
|
|
2045
|
+
|
|
2046
|
+
|
|
2047
|
+
|
|
1961
2048
|
|
|
1962
2049
|
|
|
1963
2050
|
|
|
@@ -2036,6 +2123,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2036
2123
|
|
|
2037
2124
|
|
|
2038
2125
|
|
|
2126
|
+
|
|
2127
|
+
|
|
2128
|
+
|
|
2039
2129
|
|
|
2040
2130
|
|
|
2041
2131
|
|
|
@@ -2102,6 +2192,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2102
2192
|
|
|
2103
2193
|
|
|
2104
2194
|
|
|
2195
|
+
|
|
2196
|
+
|
|
2197
|
+
|
|
2105
2198
|
|
|
2106
2199
|
|
|
2107
2200
|
|
|
@@ -2175,6 +2268,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2175
2268
|
|
|
2176
2269
|
|
|
2177
2270
|
|
|
2271
|
+
|
|
2272
|
+
|
|
2273
|
+
|
|
2178
2274
|
|
|
2179
2275
|
|
|
2180
2276
|
|
|
@@ -2238,6 +2334,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2238
2334
|
|
|
2239
2335
|
|
|
2240
2336
|
|
|
2337
|
+
|
|
2338
|
+
|
|
2339
|
+
|
|
2241
2340
|
|
|
2242
2341
|
|
|
2243
2342
|
|
|
@@ -2294,6 +2393,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2294
2393
|
|
|
2295
2394
|
|
|
2296
2395
|
|
|
2396
|
+
|
|
2397
|
+
|
|
2398
|
+
|
|
2297
2399
|
|
|
2298
2400
|
|
|
2299
2401
|
|
|
@@ -2406,6 +2508,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2406
2508
|
|
|
2407
2509
|
|
|
2408
2510
|
|
|
2511
|
+
|
|
2512
|
+
|
|
2513
|
+
|
|
2409
2514
|
|
|
2410
2515
|
|
|
2411
2516
|
|
|
@@ -2456,6 +2561,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2456
2561
|
|
|
2457
2562
|
|
|
2458
2563
|
|
|
2564
|
+
|
|
2565
|
+
|
|
2566
|
+
|
|
2459
2567
|
|
|
2460
2568
|
|
|
2461
2569
|
|
|
@@ -2529,6 +2637,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2529
2637
|
|
|
2530
2638
|
|
|
2531
2639
|
|
|
2640
|
+
|
|
2641
|
+
|
|
2642
|
+
|
|
2532
2643
|
|
|
2533
2644
|
|
|
2534
2645
|
|
|
@@ -2586,6 +2697,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2586
2697
|
|
|
2587
2698
|
|
|
2588
2699
|
|
|
2700
|
+
|
|
2701
|
+
|
|
2702
|
+
|
|
2589
2703
|
|
|
2590
2704
|
|
|
2591
2705
|
|
|
@@ -2647,6 +2761,9 @@ var Queue = class _Queue extends LinearBase {
|
|
|
2647
2761
|
|
|
2648
2762
|
|
|
2649
2763
|
|
|
2764
|
+
|
|
2765
|
+
|
|
2766
|
+
|
|
2650
2767
|
|
|
2651
2768
|
|
|
2652
2769
|
|
|
@@ -3790,6 +3907,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3790
3907
|
|
|
3791
3908
|
|
|
3792
3909
|
|
|
3910
|
+
|
|
3911
|
+
|
|
3912
|
+
|
|
3793
3913
|
|
|
3794
3914
|
|
|
3795
3915
|
|
|
@@ -3882,6 +4002,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3882
4002
|
|
|
3883
4003
|
|
|
3884
4004
|
|
|
4005
|
+
|
|
4006
|
+
|
|
4007
|
+
|
|
3885
4008
|
|
|
3886
4009
|
|
|
3887
4010
|
|
|
@@ -3972,6 +4095,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
3972
4095
|
|
|
3973
4096
|
|
|
3974
4097
|
|
|
4098
|
+
|
|
4099
|
+
|
|
4100
|
+
|
|
3975
4101
|
|
|
3976
4102
|
|
|
3977
4103
|
|
|
@@ -4053,6 +4179,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4053
4179
|
|
|
4054
4180
|
|
|
4055
4181
|
|
|
4182
|
+
|
|
4183
|
+
|
|
4184
|
+
|
|
4056
4185
|
|
|
4057
4186
|
|
|
4058
4187
|
|
|
@@ -4111,6 +4240,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4111
4240
|
|
|
4112
4241
|
|
|
4113
4242
|
|
|
4243
|
+
|
|
4244
|
+
|
|
4245
|
+
|
|
4114
4246
|
|
|
4115
4247
|
|
|
4116
4248
|
|
|
@@ -4222,6 +4354,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4222
4354
|
|
|
4223
4355
|
|
|
4224
4356
|
|
|
4357
|
+
|
|
4358
|
+
|
|
4359
|
+
|
|
4225
4360
|
|
|
4226
4361
|
|
|
4227
4362
|
|
|
@@ -4314,6 +4449,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4314
4449
|
|
|
4315
4450
|
|
|
4316
4451
|
|
|
4452
|
+
|
|
4453
|
+
|
|
4454
|
+
|
|
4317
4455
|
|
|
4318
4456
|
|
|
4319
4457
|
|
|
@@ -4368,6 +4506,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4368
4506
|
|
|
4369
4507
|
|
|
4370
4508
|
|
|
4509
|
+
|
|
4510
|
+
|
|
4511
|
+
|
|
4371
4512
|
|
|
4372
4513
|
|
|
4373
4514
|
|
|
@@ -4475,6 +4616,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4475
4616
|
|
|
4476
4617
|
|
|
4477
4618
|
|
|
4619
|
+
|
|
4620
|
+
|
|
4621
|
+
|
|
4478
4622
|
|
|
4479
4623
|
|
|
4480
4624
|
|
|
@@ -4585,6 +4729,9 @@ var DirectedGraph = class _DirectedGraph extends AbstractGraph {
|
|
|
4585
4729
|
|
|
4586
4730
|
|
|
4587
4731
|
|
|
4732
|
+
|
|
4733
|
+
|
|
4734
|
+
|
|
4588
4735
|
|
|
4589
4736
|
|
|
4590
4737
|
|
|
@@ -4761,6 +4908,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4761
4908
|
|
|
4762
4909
|
|
|
4763
4910
|
|
|
4911
|
+
|
|
4912
|
+
|
|
4913
|
+
|
|
4764
4914
|
|
|
4765
4915
|
|
|
4766
4916
|
|
|
@@ -4849,6 +4999,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4849
4999
|
|
|
4850
5000
|
|
|
4851
5001
|
|
|
5002
|
+
|
|
5003
|
+
|
|
5004
|
+
|
|
4852
5005
|
|
|
4853
5006
|
|
|
4854
5007
|
|
|
@@ -4937,6 +5090,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4937
5090
|
|
|
4938
5091
|
|
|
4939
5092
|
|
|
5093
|
+
|
|
5094
|
+
|
|
5095
|
+
|
|
4940
5096
|
|
|
4941
5097
|
|
|
4942
5098
|
|
|
@@ -5039,6 +5195,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5039
5195
|
|
|
5040
5196
|
|
|
5041
5197
|
|
|
5198
|
+
|
|
5199
|
+
|
|
5200
|
+
|
|
5042
5201
|
|
|
5043
5202
|
|
|
5044
5203
|
|
|
@@ -5097,6 +5256,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5097
5256
|
|
|
5098
5257
|
|
|
5099
5258
|
|
|
5259
|
+
|
|
5260
|
+
|
|
5261
|
+
|
|
5100
5262
|
|
|
5101
5263
|
|
|
5102
5264
|
|
|
@@ -5225,6 +5387,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5225
5387
|
|
|
5226
5388
|
|
|
5227
5389
|
|
|
5390
|
+
|
|
5391
|
+
|
|
5392
|
+
|
|
5228
5393
|
|
|
5229
5394
|
|
|
5230
5395
|
|
|
@@ -5375,6 +5540,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5375
5540
|
|
|
5376
5541
|
|
|
5377
5542
|
|
|
5543
|
+
|
|
5544
|
+
|
|
5545
|
+
|
|
5378
5546
|
|
|
5379
5547
|
|
|
5380
5548
|
|
|
@@ -5447,6 +5615,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5447
5615
|
|
|
5448
5616
|
|
|
5449
5617
|
|
|
5618
|
+
|
|
5619
|
+
|
|
5620
|
+
|
|
5450
5621
|
|
|
5451
5622
|
|
|
5452
5623
|
|
|
@@ -5501,6 +5672,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
5501
5672
|
|
|
5502
5673
|
|
|
5503
5674
|
|
|
5675
|
+
|
|
5676
|
+
|
|
5677
|
+
|
|
5504
5678
|
|
|
5505
5679
|
|
|
5506
5680
|
|