data-structure-typed 2.5.1 → 2.5.2

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 (172) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/README.md +75 -17
  3. package/dist/cjs/binary-tree.cjs +2723 -139
  4. package/dist/cjs/graph.cjs +192 -6
  5. package/dist/cjs/hash.cjs +63 -15
  6. package/dist/cjs/heap.cjs +93 -31
  7. package/dist/cjs/index.cjs +3514 -379
  8. package/dist/cjs/linked-list.cjs +237 -31
  9. package/dist/cjs/matrix.cjs +47 -9
  10. package/dist/cjs/priority-queue.cjs +92 -30
  11. package/dist/cjs/queue.cjs +176 -2
  12. package/dist/cjs/stack.cjs +48 -2
  13. package/dist/cjs/trie.cjs +78 -28
  14. package/dist/cjs-legacy/binary-tree.cjs +2725 -136
  15. package/dist/cjs-legacy/graph.cjs +192 -6
  16. package/dist/cjs-legacy/hash.cjs +63 -15
  17. package/dist/cjs-legacy/heap.cjs +93 -31
  18. package/dist/cjs-legacy/index.cjs +3389 -249
  19. package/dist/cjs-legacy/linked-list.cjs +237 -31
  20. package/dist/cjs-legacy/matrix.cjs +47 -9
  21. package/dist/cjs-legacy/priority-queue.cjs +92 -30
  22. package/dist/cjs-legacy/queue.cjs +176 -2
  23. package/dist/cjs-legacy/stack.cjs +48 -2
  24. package/dist/cjs-legacy/trie.cjs +78 -28
  25. package/dist/esm/binary-tree.mjs +2723 -139
  26. package/dist/esm/graph.mjs +192 -6
  27. package/dist/esm/hash.mjs +63 -15
  28. package/dist/esm/heap.mjs +93 -31
  29. package/dist/esm/index.mjs +3514 -380
  30. package/dist/esm/linked-list.mjs +237 -31
  31. package/dist/esm/matrix.mjs +47 -9
  32. package/dist/esm/priority-queue.mjs +92 -30
  33. package/dist/esm/queue.mjs +176 -2
  34. package/dist/esm/stack.mjs +48 -2
  35. package/dist/esm/trie.mjs +78 -28
  36. package/dist/esm-legacy/binary-tree.mjs +2725 -136
  37. package/dist/esm-legacy/graph.mjs +192 -6
  38. package/dist/esm-legacy/hash.mjs +63 -15
  39. package/dist/esm-legacy/heap.mjs +93 -31
  40. package/dist/esm-legacy/index.mjs +3389 -250
  41. package/dist/esm-legacy/linked-list.mjs +237 -31
  42. package/dist/esm-legacy/matrix.mjs +47 -9
  43. package/dist/esm-legacy/priority-queue.mjs +92 -30
  44. package/dist/esm-legacy/queue.mjs +176 -2
  45. package/dist/esm-legacy/stack.mjs +48 -2
  46. package/dist/esm-legacy/trie.mjs +78 -28
  47. package/dist/types/common/error.d.ts +9 -0
  48. package/dist/types/common/index.d.ts +1 -1
  49. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +48 -0
  50. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +56 -0
  51. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +102 -2
  52. package/dist/types/data-structures/binary-tree/bst.d.ts +195 -0
  53. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +76 -0
  54. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
  55. package/dist/types/data-structures/binary-tree/tree-map.d.ts +528 -0
  56. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +531 -6
  57. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +435 -6
  58. package/dist/types/data-structures/binary-tree/tree-set.d.ts +505 -0
  59. package/dist/types/data-structures/graph/directed-graph.d.ts +40 -0
  60. package/dist/types/data-structures/graph/undirected-graph.d.ts +36 -0
  61. package/dist/types/data-structures/hash/hash-map.d.ts +44 -0
  62. package/dist/types/data-structures/heap/heap.d.ts +56 -0
  63. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +68 -0
  64. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +60 -0
  65. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +72 -0
  66. package/dist/types/data-structures/matrix/matrix.d.ts +32 -0
  67. package/dist/types/data-structures/queue/deque.d.ts +60 -0
  68. package/dist/types/data-structures/queue/queue.d.ts +48 -0
  69. package/dist/types/data-structures/stack/stack.d.ts +40 -0
  70. package/dist/types/data-structures/trie/trie.d.ts +48 -0
  71. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  72. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  73. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  74. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  75. package/dist/umd/data-structure-typed.js +3404 -265
  76. package/dist/umd/data-structure-typed.min.js +5 -5
  77. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +650 -136
  78. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
  79. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +71 -71
  80. package/docs-site-docusaurus/docs/api/classes/BST.md +591 -129
  81. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +13 -13
  82. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +15 -15
  83. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +107 -107
  84. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
  85. package/docs-site-docusaurus/docs/api/classes/Deque.md +82 -82
  86. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +82 -82
  87. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +74 -74
  88. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
  89. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
  90. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  91. package/docs-site-docusaurus/docs/api/classes/HashMap.md +47 -47
  92. package/docs-site-docusaurus/docs/api/classes/Heap.md +45 -45
  93. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +25 -25
  94. package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +33 -33
  95. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +50 -50
  96. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +55 -55
  97. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +49 -49
  98. package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
  99. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +78 -78
  100. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +82 -82
  101. package/docs-site-docusaurus/docs/api/classes/Matrix.md +31 -31
  102. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +45 -45
  103. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +45 -45
  104. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +45 -45
  105. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +45 -45
  106. package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
  107. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +44 -44
  108. package/docs-site-docusaurus/docs/api/classes/Queue.md +60 -60
  109. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +660 -146
  110. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
  111. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +78 -78
  112. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
  113. package/docs-site-docusaurus/docs/api/classes/SkipList.md +44 -44
  114. package/docs-site-docusaurus/docs/api/classes/Stack.md +39 -39
  115. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +165 -33
  116. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +162 -46
  117. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +161 -32
  118. package/docs-site-docusaurus/docs/api/classes/Trie.md +47 -47
  119. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
  120. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +81 -81
  121. package/docs-site-docusaurus/docs/guide/architecture.md +2 -0
  122. package/docs-site-docusaurus/docs/guide/concepts.md +32 -1
  123. package/docs-site-docusaurus/docs/guide/faq.md +180 -0
  124. package/docs-site-docusaurus/docs/guide/guides.md +40 -54
  125. package/docs-site-docusaurus/docs/guide/installation.md +2 -0
  126. package/docs-site-docusaurus/docs/guide/integrations.md +2 -0
  127. package/docs-site-docusaurus/docs/guide/overview.md +7 -0
  128. package/docs-site-docusaurus/docs/guide/performance.md +2 -0
  129. package/docs-site-docusaurus/docs/guide/quick-start.md +31 -0
  130. package/docs-site-docusaurus/docs/guide/use-cases/_category_.json +6 -0
  131. package/docs-site-docusaurus/docs/guide/use-cases/array-sort-alternative.md +158 -0
  132. package/docs-site-docusaurus/docs/guide/use-cases/heap-vs-sorting.md +92 -0
  133. package/docs-site-docusaurus/docs/guide/use-cases/map-vs-treemap.md +151 -0
  134. package/docs-site-docusaurus/docs/guide/use-cases/priority-queue-typescript.md +113 -0
  135. package/docs-site-docusaurus/docs/guide/use-cases/treemap-javascript.md +151 -0
  136. package/docs-site-docusaurus/docusaurus.config.ts +1 -1
  137. package/docs-site-docusaurus/src/pages/index.tsx +51 -2
  138. package/docs-site-docusaurus/static/llms.txt +37 -0
  139. package/llms.txt +37 -0
  140. package/package.json +64 -56
  141. package/src/common/error.ts +19 -1
  142. package/src/common/index.ts +1 -1
  143. package/src/data-structures/base/iterable-element-base.ts +3 -2
  144. package/src/data-structures/binary-tree/avl-tree.ts +47 -0
  145. package/src/data-structures/binary-tree/binary-indexed-tree.ts +46 -4
  146. package/src/data-structures/binary-tree/binary-tree.ts +79 -4
  147. package/src/data-structures/binary-tree/bst.ts +441 -6
  148. package/src/data-structures/binary-tree/red-black-tree.ts +73 -0
  149. package/src/data-structures/binary-tree/segment-tree.ts +18 -0
  150. package/src/data-structures/binary-tree/tree-map.ts +434 -9
  151. package/src/data-structures/binary-tree/tree-multi-map.ts +426 -5
  152. package/src/data-structures/binary-tree/tree-multi-set.ts +350 -6
  153. package/src/data-structures/binary-tree/tree-set.ts +410 -8
  154. package/src/data-structures/graph/abstract-graph.ts +2 -2
  155. package/src/data-structures/graph/directed-graph.ts +30 -0
  156. package/src/data-structures/graph/undirected-graph.ts +27 -0
  157. package/src/data-structures/hash/hash-map.ts +35 -4
  158. package/src/data-structures/heap/heap.ts +46 -4
  159. package/src/data-structures/heap/max-heap.ts +2 -2
  160. package/src/data-structures/linked-list/doubly-linked-list.ts +51 -0
  161. package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
  162. package/src/data-structures/linked-list/skip-linked-list.ts +59 -5
  163. package/src/data-structures/matrix/matrix.ts +33 -9
  164. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  165. package/src/data-structures/queue/deque.ts +45 -0
  166. package/src/data-structures/queue/queue.ts +36 -0
  167. package/src/data-structures/stack/stack.ts +30 -0
  168. package/src/data-structures/trie/trie.ts +38 -2
  169. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  170. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  171. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  172. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
@@ -175,6 +175,10 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
175
175
 
176
176
 
177
177
 
178
+
179
+
180
+
181
+
178
182
 
179
183
 
180
184
 
@@ -227,6 +231,10 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
227
231
 
228
232
 
229
233
 
234
+
235
+
236
+
237
+
230
238
 
231
239
 
232
240
 
@@ -270,6 +278,10 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
270
278
 
271
279
 
272
280
 
281
+
282
+
283
+
284
+
273
285
 
274
286
 
275
287
 
@@ -313,6 +325,10 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
313
325
 
314
326
 
315
327
 
328
+
329
+
330
+
331
+
316
332
 
317
333
 
318
334
 
@@ -364,6 +380,10 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
364
380
 
365
381
 
366
382
 
383
+
384
+
385
+
386
+
367
387
 
368
388
 
369
389
 
@@ -424,6 +444,10 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
424
444
 
425
445
 
426
446
 
447
+
448
+
449
+
450
+
427
451
 
428
452
 
429
453
 
@@ -478,6 +502,10 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
478
502
 
479
503
 
480
504
 
505
+
506
+
507
+
508
+
481
509
 
482
510
 
483
511
 
@@ -518,6 +546,10 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
518
546
 
519
547
 
520
548
 
549
+
550
+
551
+
552
+
521
553
 
522
554
 
523
555
 
@@ -562,6 +594,10 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
562
594
 
563
595
 
564
596
 
597
+
598
+
599
+
600
+
565
601
 
566
602
 
567
603
 
@@ -614,6 +650,10 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
614
650
 
615
651
 
616
652
 
653
+
654
+
655
+
656
+
617
657
 
618
658
 
619
659
 
@@ -244,6 +244,10 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
244
244
 
245
245
 
246
246
 
247
+
248
+
249
+
250
+
247
251
 
248
252
 
249
253
 
@@ -294,6 +298,10 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
294
298
 
295
299
 
296
300
 
301
+
302
+
303
+
304
+
297
305
 
298
306
 
299
307
 
@@ -339,6 +347,10 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
339
347
 
340
348
 
341
349
 
350
+
351
+
352
+
353
+
342
354
 
343
355
 
344
356
 
@@ -380,6 +392,10 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
380
392
 
381
393
 
382
394
 
395
+
396
+
397
+
398
+
383
399
 
384
400
 
385
401
 
@@ -420,6 +436,10 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
420
436
 
421
437
 
422
438
 
439
+
440
+
441
+
442
+
423
443
 
424
444
 
425
445
 
@@ -463,6 +483,10 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
463
483
 
464
484
 
465
485
 
486
+
487
+
488
+
489
+
466
490
 
467
491
 
468
492
 
@@ -531,6 +555,10 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
531
555
 
532
556
 
533
557
 
558
+
559
+
560
+
561
+
534
562
 
535
563
 
536
564
 
@@ -582,6 +610,10 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
582
610
 
583
611
 
584
612
 
613
+
614
+
615
+
616
+
585
617
 
586
618
 
587
619
 
@@ -627,6 +659,10 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
627
659
 
628
660
 
629
661
 
662
+
663
+
664
+
665
+
630
666
 
631
667
 
632
668
 
@@ -672,6 +708,10 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
672
708
 
673
709
 
674
710
 
711
+
712
+
713
+
714
+
675
715
 
676
716
 
677
717
 
@@ -714,6 +754,10 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
714
754
 
715
755
 
716
756
 
757
+
758
+
759
+
760
+
717
761
 
718
762
 
719
763
 
@@ -751,6 +795,10 @@ export declare class Trie<R = any> extends IterableElementBase<string, R> {
751
795
 
752
796
 
753
797
 
798
+
799
+
800
+
801
+
754
802
 
755
803
 
756
804
 
@@ -3,6 +3,7 @@ import type { Comparator, OptValue } from '../../common';
3
3
  type BSTBaseOptions<K, V, R> = Omit<BinaryTreeOptions<K, V, R>, 'isDuplicate'>;
4
4
  export type BSTOptions<K, V, R> = BSTBaseOptions<K, V, R> & {
5
5
  comparator?: Comparator<K>;
6
+ enableOrderStatistic?: boolean;
6
7
  };
7
8
  export type BSTNOptKey<K> = K | undefined;
8
9
  export type OptNode<NODE> = NODE | undefined;
@@ -8,6 +8,11 @@ export interface TreeMapOptions<K, V, R = [K, V]> {
8
8
  * - `false`: store values on tree nodes (Node Mode).
9
9
  */
10
10
  isMapMode?: boolean;
11
+ /**
12
+ * Enable order-statistic operations (select, rank, rangeByRank).
13
+ * When true, subtree counts are maintained on every node.
14
+ */
15
+ enableOrderStatistic?: boolean;
11
16
  /**
12
17
  * Transform raw elements into `[key, value]` entries.
13
18
  * When provided, the constructor accepts `Iterable<R>` instead of `Iterable<[K, V]>`.
@@ -8,6 +8,10 @@ export interface TreeMultiSetOptions<K, R = K> {
8
8
  * - `false`: Node Mode.
9
9
  */
10
10
  isMapMode?: boolean;
11
+ /**
12
+ * Enable order-statistic operations (select, rank, rangeByRank).
13
+ */
14
+ enableOrderStatistic?: boolean;
11
15
  /**
12
16
  * Transform raw elements into keys.
13
17
  * When provided, the constructor accepts `Iterable<R>` instead of `Iterable<K>`.
@@ -8,6 +8,10 @@ export interface TreeSetOptions<K, R = K> {
8
8
  * - `false`: store values on tree nodes (Node Mode).
9
9
  */
10
10
  isMapMode?: boolean;
11
+ /**
12
+ * Enable order-statistic operations (select, rank, rangeByRank).
13
+ */
14
+ enableOrderStatistic?: boolean;
11
15
  /**
12
16
  * Transform raw elements into keys.
13
17
  * When provided, the constructor accepts `Iterable<R>` instead of `Iterable<K>`.