binary-tree-typed 2.5.2 → 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.
Files changed (63) hide show
  1. package/dist/cjs/index.cjs +320 -55
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +320 -55
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +320 -55
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +320 -55
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
  10. package/dist/types/data-structures/base/linear-base.d.ts +6 -0
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +191 -15
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +171 -3
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1061 -167
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1232 -355
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +916 -194
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1078 -141
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
  24. package/dist/types/data-structures/heap/heap.d.ts +140 -12
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +150 -2
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +171 -0
  30. package/dist/types/data-structures/queue/queue.d.ts +97 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +72 -2
  32. package/dist/types/data-structures/trie/trie.d.ts +84 -0
  33. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  34. package/dist/umd/binary-tree-typed.js +320 -55
  35. package/dist/umd/binary-tree-typed.js.map +1 -1
  36. package/dist/umd/binary-tree-typed.min.js +5 -5
  37. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  38. package/package.json +2 -2
  39. package/src/data-structures/base/iterable-element-base.ts +32 -0
  40. package/src/data-structures/base/linear-base.ts +11 -0
  41. package/src/data-structures/binary-tree/avl-tree.ts +88 -5
  42. package/src/data-structures/binary-tree/binary-indexed-tree.ts +98 -0
  43. package/src/data-structures/binary-tree/binary-tree.ts +242 -81
  44. package/src/data-structures/binary-tree/bst.ts +173 -7
  45. package/src/data-structures/binary-tree/red-black-tree.ts +139 -15
  46. package/src/data-structures/binary-tree/segment-tree.ts +42 -0
  47. package/src/data-structures/binary-tree/tree-map.ts +948 -36
  48. package/src/data-structures/binary-tree/tree-multi-map.ts +893 -13
  49. package/src/data-structures/binary-tree/tree-multi-set.ts +761 -33
  50. package/src/data-structures/binary-tree/tree-set.ts +1260 -251
  51. package/src/data-structures/graph/directed-graph.ts +71 -1
  52. package/src/data-structures/graph/undirected-graph.ts +64 -1
  53. package/src/data-structures/hash/hash-map.ts +100 -12
  54. package/src/data-structures/heap/heap.ts +149 -19
  55. package/src/data-structures/linked-list/doubly-linked-list.ts +178 -2
  56. package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
  57. package/src/data-structures/linked-list/skip-linked-list.ts +126 -0
  58. package/src/data-structures/matrix/matrix.ts +56 -0
  59. package/src/data-structures/queue/deque.ts +187 -0
  60. package/src/data-structures/queue/queue.ts +109 -0
  61. package/src/data-structures/stack/stack.ts +75 -5
  62. package/src/data-structures/trie/trie.ts +84 -0
  63. package/src/interfaces/binary-tree.ts +1 -9
@@ -212,15 +212,6 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
212
212
 
213
213
 
214
214
 
215
- * @example
216
- * // Check empty
217
- * console.log(new TreeSet().isEmpty()); // true;
218
- */
219
- isEmpty(): boolean;
220
- private _validateKey;
221
- /**
222
- * Add a key to the set (no-op if already present).
223
- * @remarks Expected time O(log n)
224
215
 
225
216
 
226
217
 
@@ -256,6 +247,15 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
256
247
 
257
248
 
258
249
 
250
+ * @example
251
+ * // Check empty
252
+ * console.log(new TreeSet().isEmpty()); // true;
253
+ */
254
+ isEmpty(): boolean;
255
+ private _validateKey;
256
+ /**
257
+ * Add a key to the set (no-op if already present).
258
+ * @remarks Expected time O(log n)
259
259
 
260
260
 
261
261
 
@@ -382,22 +382,6 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
382
382
 
383
383
 
384
384
 
385
- * @example
386
- * // Unique tags with sorted order
387
- * const tags = new TreeSet<string>(['javascript', 'typescript', 'react', 'typescript', 'node']);
388
- *
389
- * // Duplicates removed, sorted alphabetically
390
- * console.log([...tags]); // ['javascript', 'node', 'react', 'typescript'];
391
- * console.log(tags.size); // 4;
392
- *
393
- * tags.add('angular');
394
- * console.log(tags.first()); // 'angular';
395
- * console.log(tags.last()); // 'typescript';
396
- */
397
- add(key: K): this;
398
- /**
399
- * Test whether a key exists.
400
- * @remarks Expected time O(log n)
401
385
 
402
386
 
403
387
 
@@ -468,6 +452,25 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
468
452
 
469
453
 
470
454
 
455
+ * @example
456
+ * // Unique tags with sorted order
457
+ * const tags = new TreeSet<string>(['javascript', 'typescript', 'react', 'typescript', 'node']);
458
+ *
459
+ * // Duplicates removed, sorted alphabetically
460
+ * console.log([...tags]); // ['javascript', 'node', 'react', 'typescript'];
461
+ * console.log(tags.size); // 4;
462
+ *
463
+ * tags.add('angular');
464
+ * console.log(tags.first()); // 'angular';
465
+ * console.log(tags.last()); // 'typescript';
466
+ */
467
+ add(key: K): this;
468
+ /**
469
+ * Add multiple keys at once.
470
+ * @remarks Expected time O(m log n), where m is the number of keys.
471
+ * @param keys - Iterable of keys to add.
472
+ * @returns Array of booleans indicating whether each key was newly added.
473
+
471
474
 
472
475
 
473
476
 
@@ -495,6 +498,16 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
495
498
 
496
499
 
497
500
 
501
+ * @example
502
+ * // Add multiple keys
503
+ * const ts = new TreeSet<number>();
504
+ * ts.addMany([5, 3, 7, 1, 9]);
505
+ * console.log(ts.size); // 5;
506
+ */
507
+ addMany(keys: Iterable<K>): boolean[];
508
+ /**
509
+ * Test whether a key exists.
510
+ * @remarks Expected time O(log n)
498
511
 
499
512
 
500
513
 
@@ -567,18 +580,6 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
567
580
 
568
581
 
569
582
 
570
- * @example
571
- * // Checking membership in a sorted collection
572
- * const allowed = new TreeSet<string>(['admin', 'editor', 'viewer']);
573
- *
574
- * console.log(allowed.has('admin')); // true;
575
- * console.log(allowed.has('guest')); // false;
576
- */
577
- has(key: K): boolean;
578
- /**
579
- * Delete a key.
580
- * @returns `true` if the key existed; otherwise `false`.
581
- * @remarks Expected time O(log n)
582
583
 
583
584
 
584
585
 
@@ -711,6 +712,27 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
711
712
 
712
713
 
713
714
 
715
+ * @example
716
+ * // Checking membership in a sorted collection
717
+ * const allowed = new TreeSet<string>(['admin', 'editor', 'viewer']);
718
+ *
719
+ * console.log(allowed.has('admin')); // true;
720
+ * console.log(allowed.has('guest')); // false;
721
+ */
722
+ has(key: K): boolean;
723
+ /**
724
+ * Delete a key.
725
+ * @returns `true` if the key existed; otherwise `false`.
726
+ * @remarks Expected time O(log n)
727
+
728
+
729
+
730
+
731
+
732
+
733
+
734
+
735
+
714
736
 
715
737
 
716
738
 
@@ -748,17 +770,6 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
748
770
 
749
771
 
750
772
 
751
- * @example
752
- * // Removing elements while maintaining order
753
- * const nums = new TreeSet<number>([1, 3, 5, 7, 9]);
754
- *
755
- * console.log(nums.delete(5)); // true;
756
- * console.log(nums.delete(5)); // false; // already gone
757
- * console.log([...nums]); // [1, 3, 7, 9];
758
- */
759
- delete(key: K): boolean;
760
- /**
761
- * Remove all keys.
762
773
 
763
774
 
764
775
 
@@ -918,14 +929,23 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
918
929
 
919
930
 
920
931
  * @example
921
- * // Remove all
922
- * const ts = new TreeSet<number>([1, 2]);
923
- * ts.clear();
924
- * console.log(ts.isEmpty()); // true;
932
+ * // Removing elements while maintaining order
933
+ * const nums = new TreeSet<number>([1, 3, 5, 7, 9]);
934
+ *
935
+ * console.log(nums.delete(5)); // true;
936
+ * console.log(nums.delete(5)); // false; // already gone
937
+ * console.log([...nums]); // [1, 3, 7, 9];
925
938
  */
926
- clear(): void;
939
+ delete(key: K): boolean;
927
940
  /**
928
- * Iterate over keys in ascending order.
941
+ * Delete all keys matching a predicate.
942
+ * @remarks Time O(N), Space O(N)
943
+ * @param predicate - Function (key, index, set) → boolean; return true to delete.
944
+ * @returns True if at least one key was deleted.
945
+ */
946
+ deleteWhere(predicate: (key: K, index: number, set: this) => boolean): boolean;
947
+ /**
948
+ * Remove all keys.
929
949
 
930
950
 
931
951
 
@@ -1084,16 +1104,6 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1084
1104
 
1085
1105
 
1086
1106
 
1087
- * @example
1088
- * // Get sorted keys
1089
- * const ts = new TreeSet<number>([30, 10, 20]);
1090
- * console.log([...ts.keys()]); // [10, 20, 30];
1091
- */
1092
- keys(): IterableIterator<K>;
1093
- /**
1094
- * Iterate over values in ascending order.
1095
- *
1096
- * Note: for Set-like containers, `values()` is the same as `keys()`.
1097
1107
 
1098
1108
 
1099
1109
 
@@ -1129,6 +1139,15 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1129
1139
 
1130
1140
 
1131
1141
 
1142
+ * @example
1143
+ * // Remove all
1144
+ * const ts = new TreeSet<number>([1, 2]);
1145
+ * ts.clear();
1146
+ * console.log(ts.isEmpty()); // true;
1147
+ */
1148
+ clear(): void;
1149
+ /**
1150
+ * Iterate over keys in ascending order.
1132
1151
 
1133
1152
 
1134
1153
 
@@ -1252,16 +1271,6 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1252
1271
 
1253
1272
 
1254
1273
 
1255
- * @example
1256
- * // Get values (same as keys for Set)
1257
- * const ts = new TreeSet<number>([2, 1, 3]);
1258
- * console.log([...ts.values()]); // [1, 2, 3];
1259
- */
1260
- values(): IterableIterator<K>;
1261
- /**
1262
- * Iterate over `[value, value]` pairs (native Set convention).
1263
- *
1264
- * Note: TreeSet stores only keys internally; `[k, k]` is created on-the-fly during iteration.
1265
1274
 
1266
1275
 
1267
1276
 
@@ -1332,6 +1341,16 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1332
1341
 
1333
1342
 
1334
1343
 
1344
+ * @example
1345
+ * // Get sorted keys
1346
+ * const ts = new TreeSet<number>([30, 10, 20]);
1347
+ * console.log([...ts.keys()]); // [10, 20, 30];
1348
+ */
1349
+ keys(): IterableIterator<K>;
1350
+ /**
1351
+ * Iterate over values in ascending order.
1352
+ *
1353
+ * Note: for Set-like containers, `values()` is the same as `keys()`.
1335
1354
 
1336
1355
 
1337
1356
 
@@ -1420,17 +1439,6 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1420
1439
 
1421
1440
 
1422
1441
 
1423
- * @example
1424
- * // Iterate entries
1425
- * const ts = new TreeSet<number>([3, 1, 2]);
1426
- * console.log([...ts.entries()].map(([k]) => k)); // [1, 2, 3];
1427
- */
1428
- entries(): IterableIterator<[K, K]>;
1429
- [Symbol.iterator](): IterableIterator<K>;
1430
- /**
1431
- * Visit each value in ascending order.
1432
- *
1433
- * Callback follows native Set convention: `(value, value2, set)`.
1434
1442
 
1435
1443
 
1436
1444
 
@@ -1536,6 +1544,16 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1536
1544
 
1537
1545
 
1538
1546
 
1547
+ * @example
1548
+ * // Get values (same as keys for Set)
1549
+ * const ts = new TreeSet<number>([2, 1, 3]);
1550
+ * console.log([...ts.values()]); // [1, 2, 3];
1551
+ */
1552
+ values(): IterableIterator<K>;
1553
+ /**
1554
+ * Iterate over `[value, value]` pairs (native Set convention).
1555
+ *
1556
+ * Note: TreeSet stores only keys internally; `[k, k]` is created on-the-fly during iteration.
1539
1557
 
1540
1558
 
1541
1559
 
@@ -1589,19 +1607,6 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1589
1607
 
1590
1608
 
1591
1609
 
1592
- * @example
1593
- * // Execute for each
1594
- * const ts = new TreeSet<number>([3, 1, 2]);
1595
- * const keys: number[] = [];
1596
- * ts.forEach(k => keys.push(k));
1597
- * console.log(keys); // [1, 2, 3];
1598
- */
1599
- forEach(cb: (value: K, value2: K, set: TreeSet<K>) => void, thisArg?: unknown): void;
1600
- /**
1601
- * Create a new TreeSet by mapping each value to a new key.
1602
- *
1603
- * This mirrors `RedBlackTree.map`: mapping produces a new ordered container.
1604
- * @remarks Time O(n log n) expected, Space O(n)
1605
1610
 
1606
1611
 
1607
1612
 
@@ -1742,6 +1747,17 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1742
1747
 
1743
1748
 
1744
1749
 
1750
+ * @example
1751
+ * // Iterate entries
1752
+ * const ts = new TreeSet<number>([3, 1, 2]);
1753
+ * console.log([...ts.entries()].map(([k]) => k)); // [1, 2, 3];
1754
+ */
1755
+ entries(): IterableIterator<[K, K]>;
1756
+ [Symbol.iterator](): IterableIterator<K>;
1757
+ /**
1758
+ * Visit each value in ascending order.
1759
+ *
1760
+ * Callback follows native Set convention: `(value, value2, set)`.
1745
1761
 
1746
1762
 
1747
1763
 
@@ -1760,18 +1776,6 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1760
1776
 
1761
1777
 
1762
1778
 
1763
- * @example
1764
- * // Transform
1765
- * const ts = new TreeSet<number>([1, 2, 3]);
1766
- * const doubled = ts.map(k => k * 2);
1767
- * console.log([...doubled]); // [2, 4, 6];
1768
- */
1769
- map<MK>(callbackfn: TreeSetElementCallback<K, MK, TreeSet<K>>, options?: Omit<TreeSetOptions<MK>, 'toElementFn'> & {
1770
- comparator?: (a: MK, b: MK) => number;
1771
- }, thisArg?: unknown): TreeSet<MK>;
1772
- /**
1773
- * Create a new TreeSet containing only values that satisfy the predicate.
1774
- * @remarks Time O(n log n) expected, Space O(n)
1775
1779
 
1776
1780
 
1777
1781
 
@@ -1930,16 +1934,6 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1930
1934
 
1931
1935
 
1932
1936
 
1933
- * @example
1934
- * // Filter
1935
- * const ts = new TreeSet<number>([1, 2, 3, 4, 5]);
1936
- * const evens = ts.filter(k => k % 2 === 0);
1937
- * console.log([...evens]); // [2, 4];
1938
- */
1939
- filter(callbackfn: TreeSetElementCallback<K, boolean, TreeSet<K>>, thisArg?: unknown): TreeSet<K>;
1940
- /**
1941
- * Reduce values into a single accumulator.
1942
- * @remarks Time O(n), Space O(1)
1943
1937
 
1944
1938
 
1945
1939
 
@@ -1957,6 +1951,19 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
1957
1951
 
1958
1952
 
1959
1953
 
1954
+ * @example
1955
+ * // Execute for each
1956
+ * const ts = new TreeSet<number>([3, 1, 2]);
1957
+ * const keys: number[] = [];
1958
+ * ts.forEach(k => keys.push(k));
1959
+ * console.log(keys); // [1, 2, 3];
1960
+ */
1961
+ forEach(cb: (value: K, value2: K, set: TreeSet<K>) => void, thisArg?: unknown): void;
1962
+ /**
1963
+ * Create a new TreeSet by mapping each value to a new key.
1964
+ *
1965
+ * This mirrors `RedBlackTree.map`: mapping produces a new ordered container.
1966
+ * @remarks Time O(n log n) expected, Space O(n)
1960
1967
 
1961
1968
 
1962
1969
 
@@ -2098,16 +2105,6 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2098
2105
 
2099
2106
 
2100
2107
 
2101
- * @example
2102
- * // Aggregate
2103
- * const ts = new TreeSet<number>([1, 2, 3]);
2104
- * const sum = ts.reduce((acc, k) => acc + k, 0);
2105
- * console.log(sum); // 6;
2106
- */
2107
- reduce<A>(callbackfn: TreeSetReduceCallback<K, A, TreeSet<K>>, initialValue: A): A;
2108
- /**
2109
- * Test whether all values satisfy a predicate.
2110
- * @remarks Time O(n), Space O(1)
2111
2108
 
2112
2109
 
2113
2110
 
@@ -2160,6 +2157,18 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2160
2157
 
2161
2158
 
2162
2159
 
2160
+ * @example
2161
+ * // Transform
2162
+ * const ts = new TreeSet<number>([1, 2, 3]);
2163
+ * const doubled = ts.map(k => k * 2);
2164
+ * console.log([...doubled]); // [2, 4, 6];
2165
+ */
2166
+ map<MK>(callbackfn: TreeSetElementCallback<K, MK, TreeSet<K>>, options?: Omit<TreeSetOptions<MK>, 'toElementFn'> & {
2167
+ comparator?: (a: MK, b: MK) => number;
2168
+ }, thisArg?: unknown): TreeSet<MK>;
2169
+ /**
2170
+ * Create a new TreeSet containing only values that satisfy the predicate.
2171
+ * @remarks Time O(n log n) expected, Space O(n)
2163
2172
 
2164
2173
 
2165
2174
 
@@ -2264,7 +2273,500 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2264
2273
 
2265
2274
 
2266
2275
 
2267
- * @example
2276
+
2277
+
2278
+
2279
+
2280
+
2281
+
2282
+
2283
+
2284
+
2285
+
2286
+
2287
+
2288
+
2289
+
2290
+
2291
+
2292
+
2293
+
2294
+
2295
+
2296
+
2297
+
2298
+
2299
+
2300
+
2301
+
2302
+
2303
+
2304
+
2305
+
2306
+
2307
+
2308
+
2309
+
2310
+
2311
+
2312
+
2313
+
2314
+
2315
+
2316
+
2317
+
2318
+
2319
+
2320
+
2321
+
2322
+
2323
+
2324
+
2325
+
2326
+
2327
+
2328
+
2329
+
2330
+
2331
+
2332
+
2333
+
2334
+
2335
+
2336
+
2337
+
2338
+
2339
+
2340
+
2341
+
2342
+
2343
+
2344
+
2345
+
2346
+
2347
+
2348
+
2349
+
2350
+
2351
+
2352
+
2353
+
2354
+
2355
+
2356
+
2357
+
2358
+
2359
+
2360
+
2361
+
2362
+
2363
+
2364
+
2365
+ * @example
2366
+ * // Filter
2367
+ * const ts = new TreeSet<number>([1, 2, 3, 4, 5]);
2368
+ * const evens = ts.filter(k => k % 2 === 0);
2369
+ * console.log([...evens]); // [2, 4];
2370
+ */
2371
+ filter(callbackfn: TreeSetElementCallback<K, boolean, TreeSet<K>>, thisArg?: unknown): TreeSet<K>;
2372
+ /**
2373
+ * Reduce values into a single accumulator.
2374
+ * @remarks Time O(n), Space O(1)
2375
+
2376
+
2377
+
2378
+
2379
+
2380
+
2381
+
2382
+
2383
+
2384
+
2385
+
2386
+
2387
+
2388
+
2389
+
2390
+
2391
+
2392
+
2393
+
2394
+
2395
+
2396
+
2397
+
2398
+
2399
+
2400
+
2401
+
2402
+
2403
+
2404
+
2405
+
2406
+
2407
+
2408
+
2409
+
2410
+
2411
+
2412
+
2413
+
2414
+
2415
+
2416
+
2417
+
2418
+
2419
+
2420
+
2421
+
2422
+
2423
+
2424
+
2425
+
2426
+
2427
+
2428
+
2429
+
2430
+
2431
+
2432
+
2433
+
2434
+
2435
+
2436
+
2437
+
2438
+
2439
+
2440
+
2441
+
2442
+
2443
+
2444
+
2445
+
2446
+
2447
+
2448
+
2449
+
2450
+
2451
+
2452
+
2453
+
2454
+
2455
+
2456
+
2457
+
2458
+
2459
+
2460
+
2461
+
2462
+
2463
+
2464
+
2465
+
2466
+
2467
+
2468
+
2469
+
2470
+
2471
+
2472
+
2473
+
2474
+
2475
+
2476
+
2477
+
2478
+
2479
+
2480
+
2481
+
2482
+
2483
+
2484
+
2485
+
2486
+
2487
+
2488
+
2489
+
2490
+
2491
+
2492
+
2493
+
2494
+
2495
+
2496
+
2497
+
2498
+
2499
+
2500
+
2501
+
2502
+
2503
+
2504
+
2505
+
2506
+
2507
+
2508
+
2509
+
2510
+
2511
+
2512
+
2513
+
2514
+
2515
+
2516
+
2517
+
2518
+
2519
+
2520
+
2521
+
2522
+
2523
+
2524
+
2525
+
2526
+
2527
+
2528
+
2529
+
2530
+
2531
+
2532
+
2533
+
2534
+
2535
+
2536
+
2537
+
2538
+
2539
+
2540
+
2541
+
2542
+
2543
+
2544
+
2545
+
2546
+
2547
+
2548
+
2549
+
2550
+
2551
+
2552
+
2553
+
2554
+
2555
+
2556
+
2557
+
2558
+
2559
+
2560
+
2561
+
2562
+
2563
+
2564
+
2565
+
2566
+
2567
+
2568
+ * @example
2569
+ * // Aggregate
2570
+ * const ts = new TreeSet<number>([1, 2, 3]);
2571
+ * const sum = ts.reduce((acc, k) => acc + k, 0);
2572
+ * console.log(sum); // 6;
2573
+ */
2574
+ reduce<A>(callbackfn: TreeSetReduceCallback<K, A, TreeSet<K>>, initialValue: A): A;
2575
+ /**
2576
+ * Test whether all values satisfy a predicate.
2577
+ * @remarks Time O(n), Space O(1)
2578
+
2579
+
2580
+
2581
+
2582
+
2583
+
2584
+
2585
+
2586
+
2587
+
2588
+
2589
+
2590
+
2591
+
2592
+
2593
+
2594
+
2595
+
2596
+
2597
+
2598
+
2599
+
2600
+
2601
+
2602
+
2603
+
2604
+
2605
+
2606
+
2607
+
2608
+
2609
+
2610
+
2611
+
2612
+
2613
+
2614
+
2615
+
2616
+
2617
+
2618
+
2619
+
2620
+
2621
+
2622
+
2623
+
2624
+
2625
+
2626
+
2627
+
2628
+
2629
+
2630
+
2631
+
2632
+
2633
+
2634
+
2635
+
2636
+
2637
+
2638
+
2639
+
2640
+
2641
+
2642
+
2643
+
2644
+
2645
+
2646
+
2647
+
2648
+
2649
+
2650
+
2651
+
2652
+
2653
+
2654
+
2655
+
2656
+
2657
+
2658
+
2659
+
2660
+
2661
+
2662
+
2663
+
2664
+
2665
+
2666
+
2667
+
2668
+
2669
+
2670
+
2671
+
2672
+
2673
+
2674
+
2675
+
2676
+
2677
+
2678
+
2679
+
2680
+
2681
+
2682
+
2683
+
2684
+
2685
+
2686
+
2687
+
2688
+
2689
+
2690
+
2691
+
2692
+
2693
+
2694
+
2695
+
2696
+
2697
+
2698
+
2699
+
2700
+
2701
+
2702
+
2703
+
2704
+
2705
+
2706
+
2707
+
2708
+
2709
+
2710
+
2711
+
2712
+
2713
+
2714
+
2715
+
2716
+
2717
+
2718
+
2719
+
2720
+
2721
+
2722
+
2723
+
2724
+
2725
+
2726
+
2727
+
2728
+
2729
+
2730
+
2731
+
2732
+
2733
+
2734
+
2735
+
2736
+
2737
+
2738
+
2739
+
2740
+
2741
+
2742
+
2743
+
2744
+
2745
+
2746
+
2747
+
2748
+
2749
+
2750
+
2751
+
2752
+
2753
+
2754
+
2755
+
2756
+
2757
+
2758
+
2759
+
2760
+
2761
+
2762
+
2763
+
2764
+
2765
+
2766
+
2767
+
2768
+
2769
+ * @example
2268
2770
  * // Test all
2269
2771
  * const ts = new TreeSet<number>([2, 4, 6]);
2270
2772
  * console.log(ts.every(k => k > 0)); // true;
@@ -2408,6 +2910,41 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2408
2910
 
2409
2911
 
2410
2912
 
2913
+
2914
+
2915
+
2916
+
2917
+
2918
+
2919
+
2920
+
2921
+
2922
+
2923
+
2924
+
2925
+
2926
+
2927
+
2928
+
2929
+
2930
+
2931
+
2932
+
2933
+
2934
+
2935
+
2936
+
2937
+
2938
+
2939
+
2940
+
2941
+
2942
+
2943
+
2944
+
2945
+
2946
+
2947
+
2411
2948
 
2412
2949
 
2413
2950
 
@@ -2573,6 +3110,41 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2573
3110
 
2574
3111
 
2575
3112
 
3113
+
3114
+
3115
+
3116
+
3117
+
3118
+
3119
+
3120
+
3121
+
3122
+
3123
+
3124
+
3125
+
3126
+
3127
+
3128
+
3129
+
3130
+
3131
+
3132
+
3133
+
3134
+
3135
+
3136
+
3137
+
3138
+
3139
+
3140
+
3141
+
3142
+
3143
+
3144
+
3145
+
3146
+
3147
+
2576
3148
 
2577
3149
 
2578
3150
 
@@ -2762,15 +3334,85 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2762
3334
 
2763
3335
 
2764
3336
 
2765
- * @example
2766
- * // Convert to array
2767
- * const ts = new TreeSet<number>([3, 1, 2]);
2768
- * console.log(ts.toArray()); // [1, 2, 3];
2769
- */
2770
- toArray(): K[];
2771
- /**
2772
- * Print a human-friendly representation.
2773
- * @remarks Time O(n), Space O(n)
3337
+
3338
+
3339
+
3340
+
3341
+
3342
+
3343
+
3344
+
3345
+
3346
+
3347
+
3348
+
3349
+
3350
+
3351
+
3352
+
3353
+
3354
+
3355
+
3356
+
3357
+
3358
+
3359
+
3360
+
3361
+
3362
+
3363
+
3364
+
3365
+
3366
+
3367
+
3368
+
3369
+
3370
+
3371
+
3372
+ * @example
3373
+ * // Convert to array
3374
+ * const ts = new TreeSet<number>([3, 1, 2]);
3375
+ * console.log(ts.toArray()); // [1, 2, 3];
3376
+ */
3377
+ toArray(): K[];
3378
+ /**
3379
+ * Print a human-friendly representation.
3380
+ * @remarks Time O(n), Space O(n)
3381
+
3382
+
3383
+
3384
+
3385
+
3386
+
3387
+
3388
+
3389
+
3390
+
3391
+
3392
+
3393
+
3394
+
3395
+
3396
+
3397
+
3398
+
3399
+
3400
+
3401
+
3402
+
3403
+
3404
+
3405
+
3406
+
3407
+
3408
+
3409
+
3410
+
3411
+
3412
+
3413
+
3414
+
3415
+
2774
3416
 
2775
3417
 
2776
3418
 
@@ -2964,6 +3606,13 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
2964
3606
 
2965
3607
 
2966
3608
 
3609
+
3610
+
3611
+
3612
+
3613
+
3614
+
3615
+
2967
3616
 
2968
3617
 
2969
3618
 
@@ -3030,6 +3679,13 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3030
3679
 
3031
3680
 
3032
3681
 
3682
+
3683
+
3684
+
3685
+
3686
+
3687
+
3688
+
3033
3689
 
3034
3690
 
3035
3691
 
@@ -3074,6 +3730,13 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3074
3730
 
3075
3731
 
3076
3732
 
3733
+
3734
+
3735
+
3736
+
3737
+
3738
+
3739
+
3077
3740
 
3078
3741
 
3079
3742
 
@@ -3120,6 +3783,13 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3120
3783
 
3121
3784
 
3122
3785
 
3786
+
3787
+
3788
+
3789
+
3790
+
3791
+
3792
+
3123
3793
 
3124
3794
 
3125
3795
 
@@ -3251,6 +3921,34 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3251
3921
 
3252
3922
 
3253
3923
 
3924
+
3925
+
3926
+
3927
+
3928
+
3929
+
3930
+
3931
+
3932
+
3933
+
3934
+
3935
+
3936
+
3937
+
3938
+
3939
+
3940
+
3941
+
3942
+
3943
+
3944
+
3945
+
3946
+
3947
+
3948
+
3949
+
3950
+
3951
+
3254
3952
 
3255
3953
 
3256
3954
 
@@ -3405,6 +4103,34 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3405
4103
 
3406
4104
 
3407
4105
 
4106
+
4107
+
4108
+
4109
+
4110
+
4111
+
4112
+
4113
+
4114
+
4115
+
4116
+
4117
+
4118
+
4119
+
4120
+
4121
+
4122
+
4123
+
4124
+
4125
+
4126
+
4127
+
4128
+
4129
+
4130
+
4131
+
4132
+
4133
+
3408
4134
 
3409
4135
 
3410
4136
 
@@ -3551,6 +4277,34 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3551
4277
 
3552
4278
 
3553
4279
 
4280
+
4281
+
4282
+
4283
+
4284
+
4285
+
4286
+
4287
+
4288
+
4289
+
4290
+
4291
+
4292
+
4293
+
4294
+
4295
+
4296
+
4297
+
4298
+
4299
+
4300
+
4301
+
4302
+
4303
+
4304
+
4305
+
4306
+
4307
+
3554
4308
 
3555
4309
 
3556
4310
 
@@ -3695,6 +4449,34 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3695
4449
 
3696
4450
 
3697
4451
 
4452
+
4453
+
4454
+
4455
+
4456
+
4457
+
4458
+
4459
+
4460
+
4461
+
4462
+
4463
+
4464
+
4465
+
4466
+
4467
+
4468
+
4469
+
4470
+
4471
+
4472
+
4473
+
4474
+
4475
+
4476
+
4477
+
4478
+
4479
+
3698
4480
 
3699
4481
 
3700
4482
 
@@ -3842,6 +4624,34 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3842
4624
 
3843
4625
 
3844
4626
 
4627
+
4628
+
4629
+
4630
+
4631
+
4632
+
4633
+
4634
+
4635
+
4636
+
4637
+
4638
+
4639
+
4640
+
4641
+
4642
+
4643
+
4644
+
4645
+
4646
+
4647
+
4648
+
4649
+
4650
+
4651
+
4652
+
4653
+
4654
+
3845
4655
 
3846
4656
 
3847
4657
 
@@ -3915,8 +4725,22 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
3915
4725
  * Returns elements by rank range (0-indexed, inclusive on both ends).
3916
4726
  * @remarks Time O(log n + k). Requires `enableOrderStatistic: true`.
3917
4727
 
4728
+
4729
+
4730
+
4731
+
4732
+
4733
+
4734
+
4735
+
4736
+
4737
+
4738
+
4739
+
4740
+
4741
+
3918
4742
  * @example
3919
- * // Pagination with rangeByRank
4743
+ * // Pagination by position in tree order
3920
4744
  * const tree = new TreeSet<number>(
3921
4745
  * [10, 20, 30, 40, 50, 60, 70, 80, 90],
3922
4746
  * { enableOrderStatistic: true }
@@ -4072,6 +4896,31 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
4072
4896
 
4073
4897
 
4074
4898
 
4899
+
4900
+
4901
+
4902
+
4903
+
4904
+
4905
+
4906
+
4907
+
4908
+
4909
+
4910
+
4911
+
4912
+
4913
+
4914
+
4915
+
4916
+
4917
+
4918
+
4919
+
4920
+
4921
+
4922
+
4923
+
4075
4924
 
4076
4925
 
4077
4926
 
@@ -4100,5 +4949,93 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
4100
4949
  * copy.delete(1);
4101
4950
  * console.log(ts.has(1)); // true;
4102
4951
  */
4952
+ /**
4953
+ * Return a new TreeSet containing all elements from both sets.
4954
+ * @remarks When both sets share the same comparator, uses O(n+m) merge. Otherwise O(m log n).
4955
+ * @param other - Any iterable of keys.
4956
+ * @returns A new TreeSet.
4957
+ * @example
4958
+ * // Merge two sets
4959
+ * console.log([...a.union(b)]); // [1, 2, 3, 4, 5, 6, 7];
4960
+ */
4961
+ union(other: Iterable<K>): TreeSet<K>;
4962
+ /**
4963
+ * Return a new TreeSet containing only elements present in both sets.
4964
+ * @remarks Time O(n+m) with ordered merge when possible, otherwise O(n log m).
4965
+ * @param other - Any iterable of keys (converted to Set for fast lookup if not a TreeSet).
4966
+ * @returns A new TreeSet.
4967
+ * @example
4968
+ * // Find common elements
4969
+ * console.log([...a.intersection(b)]); // [3, 4, 5];
4970
+ */
4971
+ intersection(other: Iterable<K>): TreeSet<K>;
4972
+ /**
4973
+ * Return a new TreeSet containing elements in this set but not in the other.
4974
+ * @remarks Time O(n+m) with ordered merge when possible, otherwise O(n log m).
4975
+ * @param other - Any iterable of keys.
4976
+ * @returns A new TreeSet.
4977
+ * @example
4978
+ * // Find exclusive elements
4979
+ * console.log([...a.difference(b)]); // [1, 2];
4980
+ */
4981
+ difference(other: Iterable<K>): TreeSet<K>;
4982
+ /**
4983
+ * Return a new TreeSet containing elements in either set but not both.
4984
+ * @remarks Time O(n+m).
4985
+ * @param other - Any iterable of keys.
4986
+ * @returns A new TreeSet.
4987
+ * @example
4988
+ * // Find symmetric difference
4989
+ * console.log([...a.symmetricDifference(b)]); // [1, 2, 6, 7];
4990
+ */
4991
+ symmetricDifference(other: Iterable<K>): TreeSet<K>;
4992
+ /**
4993
+ * Check whether every element in this set is also in the other.
4994
+ * @remarks Time O(n).
4995
+ * @param other - Any iterable of keys (converted to Set for fast lookup if not a TreeSet).
4996
+ * @returns `true` if this is a subset of other.
4997
+ * @example
4998
+ * // Check subset
4999
+ * console.log(new TreeSet([3, 4]).isSubsetOf(a)); // true;
5000
+ */
5001
+ isSubsetOf(other: Iterable<K>): boolean;
5002
+ /**
5003
+ * Check whether every element in the other set is also in this set.
5004
+ * @remarks Time O(m).
5005
+ * @param other - Any iterable of keys.
5006
+ * @returns `true` if this is a superset of other.
5007
+ * @example
5008
+ * // Check superset
5009
+ * console.log(a.isSupersetOf(new TreeSet([2, 3]))); // true;
5010
+ */
5011
+ isSupersetOf(other: Iterable<K>): boolean;
5012
+ /**
5013
+ * Check whether this set and the other share no common elements.
5014
+ * @remarks Time O(min(n,m)), can short-circuit on first overlap.
5015
+ * @param other - Any iterable of keys (converted to Set for fast lookup if not a TreeSet).
5016
+ * @returns `true` if sets are disjoint.
5017
+ * @example
5018
+ * // Check disjoint
5019
+ * console.log(a.isDisjointFrom(new TreeSet([8, 9]))); // true;
5020
+ */
5021
+ isDisjointFrom(other: Iterable<K>): boolean;
5022
+ /**
5023
+ * Deep copy
5024
+
5025
+
5026
+
5027
+
5028
+
5029
+
5030
+
5031
+
5032
+
5033
+ * @example
5034
+ * // Deep clone
5035
+ * const ts = new TreeSet<number>([1, 2, 3]);
5036
+ * const copy = ts.clone();
5037
+ * copy.delete(1);
5038
+ * console.log(ts.has(1)); // true;
5039
+ */
4103
5040
  clone(): TreeSet<K>;
4104
5041
  }