undirected-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 +144 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +144 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +144 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +144 -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/undirected-graph-typed.js +144 -0
- package/dist/umd/undirected-graph-typed.js.map +1 -1
- package/dist/umd/undirected-graph-typed.min.js +1 -1
- package/dist/umd/undirected-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
|
|
|
@@ -3779,6 +3896,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
3779
3896
|
|
|
3780
3897
|
|
|
3781
3898
|
|
|
3899
|
+
|
|
3900
|
+
|
|
3901
|
+
|
|
3782
3902
|
|
|
3783
3903
|
|
|
3784
3904
|
|
|
@@ -3867,6 +3987,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
3867
3987
|
|
|
3868
3988
|
|
|
3869
3989
|
|
|
3990
|
+
|
|
3991
|
+
|
|
3992
|
+
|
|
3870
3993
|
|
|
3871
3994
|
|
|
3872
3995
|
|
|
@@ -3955,6 +4078,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
3955
4078
|
|
|
3956
4079
|
|
|
3957
4080
|
|
|
4081
|
+
|
|
4082
|
+
|
|
4083
|
+
|
|
3958
4084
|
|
|
3959
4085
|
|
|
3960
4086
|
|
|
@@ -4057,6 +4183,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4057
4183
|
|
|
4058
4184
|
|
|
4059
4185
|
|
|
4186
|
+
|
|
4187
|
+
|
|
4188
|
+
|
|
4060
4189
|
|
|
4061
4190
|
|
|
4062
4191
|
|
|
@@ -4115,6 +4244,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4115
4244
|
|
|
4116
4245
|
|
|
4117
4246
|
|
|
4247
|
+
|
|
4248
|
+
|
|
4249
|
+
|
|
4118
4250
|
|
|
4119
4251
|
|
|
4120
4252
|
|
|
@@ -4243,6 +4375,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4243
4375
|
|
|
4244
4376
|
|
|
4245
4377
|
|
|
4378
|
+
|
|
4379
|
+
|
|
4380
|
+
|
|
4246
4381
|
|
|
4247
4382
|
|
|
4248
4383
|
|
|
@@ -4393,6 +4528,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4393
4528
|
|
|
4394
4529
|
|
|
4395
4530
|
|
|
4531
|
+
|
|
4532
|
+
|
|
4533
|
+
|
|
4396
4534
|
|
|
4397
4535
|
|
|
4398
4536
|
|
|
@@ -4465,6 +4603,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4465
4603
|
|
|
4466
4604
|
|
|
4467
4605
|
|
|
4606
|
+
|
|
4607
|
+
|
|
4608
|
+
|
|
4468
4609
|
|
|
4469
4610
|
|
|
4470
4611
|
|
|
@@ -4519,6 +4660,9 @@ var UndirectedGraph = class _UndirectedGraph extends AbstractGraph {
|
|
|
4519
4660
|
|
|
4520
4661
|
|
|
4521
4662
|
|
|
4663
|
+
|
|
4664
|
+
|
|
4665
|
+
|
|
4522
4666
|
|
|
4523
4667
|
|
|
4524
4668
|
|