data-structure-typed 2.4.4 → 2.5.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 (80) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/README.md +34 -1
  3. package/dist/cjs/index.cjs +10639 -2151
  4. package/dist/cjs-legacy/index.cjs +10694 -2195
  5. package/dist/esm/index.mjs +10639 -2150
  6. package/dist/esm-legacy/index.mjs +10694 -2194
  7. package/dist/types/common/error.d.ts +23 -0
  8. package/dist/types/common/index.d.ts +1 -0
  9. package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
  10. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +128 -51
  11. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +210 -164
  12. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +439 -78
  13. package/dist/types/data-structures/binary-tree/bst.d.ts +311 -28
  14. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +217 -31
  15. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +218 -152
  16. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1281 -5
  17. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1087 -201
  18. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +858 -65
  19. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1133 -5
  20. package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -0
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +220 -47
  22. package/dist/types/data-structures/graph/map-graph.d.ts +59 -1
  23. package/dist/types/data-structures/graph/undirected-graph.d.ts +218 -59
  24. package/dist/types/data-structures/hash/hash-map.d.ts +230 -77
  25. package/dist/types/data-structures/heap/heap.d.ts +287 -99
  26. package/dist/types/data-structures/heap/max-heap.d.ts +46 -0
  27. package/dist/types/data-structures/heap/min-heap.d.ts +59 -0
  28. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +286 -44
  29. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +278 -65
  30. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +415 -12
  31. package/dist/types/data-structures/matrix/matrix.d.ts +331 -0
  32. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +57 -0
  33. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +60 -0
  34. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +60 -0
  35. package/dist/types/data-structures/queue/deque.d.ts +313 -66
  36. package/dist/types/data-structures/queue/queue.d.ts +211 -42
  37. package/dist/types/data-structures/stack/stack.d.ts +174 -32
  38. package/dist/types/data-structures/trie/trie.d.ts +213 -43
  39. package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -1
  40. package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +1 -4
  41. package/dist/types/types/data-structures/queue/deque.d.ts +6 -0
  42. package/dist/umd/data-structure-typed.js +10725 -2221
  43. package/dist/umd/data-structure-typed.min.js +4 -2
  44. package/package.json +5 -4
  45. package/src/common/error.ts +60 -0
  46. package/src/common/index.ts +2 -0
  47. package/src/data-structures/base/iterable-element-base.ts +2 -2
  48. package/src/data-structures/binary-tree/avl-tree.ts +146 -51
  49. package/src/data-structures/binary-tree/binary-indexed-tree.ts +317 -247
  50. package/src/data-structures/binary-tree/binary-tree.ts +567 -121
  51. package/src/data-structures/binary-tree/bst.ts +370 -37
  52. package/src/data-structures/binary-tree/red-black-tree.ts +328 -96
  53. package/src/data-structures/binary-tree/segment-tree.ts +378 -248
  54. package/src/data-structures/binary-tree/tree-map.ts +1411 -13
  55. package/src/data-structures/binary-tree/tree-multi-map.ts +1218 -215
  56. package/src/data-structures/binary-tree/tree-multi-set.ts +959 -69
  57. package/src/data-structures/binary-tree/tree-set.ts +1257 -15
  58. package/src/data-structures/graph/abstract-graph.ts +106 -1
  59. package/src/data-structures/graph/directed-graph.ts +233 -47
  60. package/src/data-structures/graph/map-graph.ts +59 -1
  61. package/src/data-structures/graph/undirected-graph.ts +308 -59
  62. package/src/data-structures/hash/hash-map.ts +254 -79
  63. package/src/data-structures/heap/heap.ts +305 -102
  64. package/src/data-structures/heap/max-heap.ts +48 -3
  65. package/src/data-structures/heap/min-heap.ts +59 -0
  66. package/src/data-structures/linked-list/doubly-linked-list.ts +303 -44
  67. package/src/data-structures/linked-list/singly-linked-list.ts +293 -65
  68. package/src/data-structures/linked-list/skip-linked-list.ts +707 -90
  69. package/src/data-structures/matrix/matrix.ts +433 -22
  70. package/src/data-structures/priority-queue/max-priority-queue.ts +59 -3
  71. package/src/data-structures/priority-queue/min-priority-queue.ts +60 -0
  72. package/src/data-structures/priority-queue/priority-queue.ts +60 -0
  73. package/src/data-structures/queue/deque.ts +358 -68
  74. package/src/data-structures/queue/queue.ts +223 -42
  75. package/src/data-structures/stack/stack.ts +184 -32
  76. package/src/data-structures/trie/trie.ts +227 -44
  77. package/src/types/data-structures/binary-tree/segment-tree.ts +1 -1
  78. package/src/types/data-structures/linked-list/skip-linked-list.ts +2 -1
  79. package/src/types/data-structures/queue/deque.ts +7 -0
  80. package/src/utils/utils.ts +4 -2
package/CHANGELOG.md CHANGED
@@ -8,7 +8,28 @@ All notable changes to this project will be documented in this file.
8
8
  - [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
9
9
  - [`auto-changelog`](https://github.com/CookPete/auto-changelog)
10
10
 
11
- ## [v2.4.4](https://github.com/zrwusa/data-structure-typed/compare/v2.4.3...main) (upcoming)
11
+ ## [v2.5.0](https://github.com/zrwusa/data-structure-typed/compare/v2.4.3...main) (upcoming)
12
+
13
+ ### Changes
14
+
15
+ - fix(binary-tree): null nodes no longer count toward size [`#70`](https://github.com/zrwusa/data-structure-typed/pull/70)
16
+ - feat(graph): add biconnected components and cycle detection for undirected graph [`#77`](https://github.com/zrwusa/data-structure-typed/pull/77)
17
+ - fix(rbt): override perfectlyBalance to preserve RBT invariants [`#79`](https://github.com/zrwusa/data-structure-typed/pull/79)
18
+ - feat(bst): support Date keys in default comparator [`#107`](https://github.com/zrwusa/data-structure-typed/pull/107)
19
+ - refactor(binary-tree): iterative _displayAux to prevent stack overflow on deep trees [`#104`](https://github.com/zrwusa/data-structure-typed/pull/104)
20
+ - fix(binary-tree): leaves() iterative mode uses DFS stack to match recursive order [`#102`](https://github.com/zrwusa/data-structure-typed/pull/102)
21
+ - refactor: migrate all throw sites to ERR message templates [`#130`](https://github.com/zrwusa/data-structure-typed/pull/130)
22
+ - refactor: lightweight centralized error messages via ERR templates [`#130`](https://github.com/zrwusa/data-structure-typed/pull/130)
23
+ - feat: centralized error handling with DSTError/DSTRangeError/DSTTypeError [`#130`](https://github.com/zrwusa/data-structure-typed/pull/130)
24
+ - refactor(deque): improve auto-compact with counter + element-based ratio [`#92`](https://github.com/zrwusa/data-structure-typed/pull/92)
25
+ - perf(deque): optimize auto-compact with counter-based checking and element ratio [`#92`](https://github.com/zrwusa/data-structure-typed/pull/92)
26
+ - feat(deque): add compact() method and autoCompactRatio option [`#92`](https://github.com/zrwusa/data-structure-typed/pull/92)
27
+ - fix(deque): add constructor overloads for better type inference [`#97`](https://github.com/zrwusa/data-structure-typed/pull/97)
28
+ - test(graph): add edge case tests for visual output [`#113`](https://github.com/zrwusa/data-structure-typed/pull/113)
29
+ - test(graph): add visual output tests for DirectedGraph and UndirectedGraph [`#113`](https://github.com/zrwusa/data-structure-typed/pull/113)
30
+ - feat(graph): add print, toVisual, and toDot methods for all graphs [`#113`](https://github.com/zrwusa/data-structure-typed/pull/113)
31
+ - fix(hash-map): deleteAt/deleteWhere now removes entry from hash table [`#99`](https://github.com/zrwusa/data-structure-typed/pull/99)
32
+ - fix(deque): shrinkToFit now updates _bucketCount and handles single-bucket case [`#98`](https://github.com/zrwusa/data-structure-typed/pull/98)
12
33
 
13
34
  ## [v2.4.3](https://github.com/zrwusa/data-structure-typed/compare/v2.2.3...v2.4.3) (3 March 2026)
14
35
 
package/README.md CHANGED
@@ -130,7 +130,30 @@ for (let i = 0; i < 100000; i++) {
130
130
 
131
131
  - **Tree-shakable** ESM / CJS / legacy builds
132
132
 
133
- šŸ“Š [Full benchmarks →](./docs/benchmark.html)
133
+ [//]: # (No deletion!!! Start of README Performance Section)
134
+
135
+ | Data Structure | Test Case | DST (ms) | Native (ms) | C++ (ms) | js-sdsl (ms) |
136
+ |----------------|-----------|----------|-------------|----------|---------------|
137
+ | Queue | 1M push | 26.93 | 23.83 | 1.70 | 27.59 |
138
+ | Deque | 1M push | 9.77 | 26.81 | 1.76 | 7.79 |
139
+ | DoublyLinkedList | 100k push | 5.70 | 2.40 | 5.70 | 1.90 |
140
+ | SinglyLinkedList | 100K unshift & shift | 3.77 | 1958.39 | 4.80 | - |
141
+ | PriorityQueue | 100K add | 4.00 | - | 1.05 | 4.96 |
142
+ | TreeSet | 1M add | 995.72 | - | 462.00 | 677.58 |
143
+ | TreeMap | 1M set | 978.72 | - | 512.00 | 623.23 |
144
+ | TreeMultiSet | 1M add (TreeMultiSet expanded iteration) | 217.73 | - | 752.00 | - |
145
+ | TreeMultiMap | 1M add (TreeMultiMap bucketed) | 366.19 | - | 731.00 | - |
146
+ | RedBlackTree | 1M get | 99.24 | - | 52.97 | - |
147
+ | BST | 10K add randomly | 5.50 | - | - | - |
148
+ | BinaryTree | 1K add randomly | 9.77 | - | - | - |
149
+ | HashMap | 1M set | 146.17 | 144.83 | 76.26 | 94.16 |
150
+ | Trie | 100K add | 141.10 | - | - | - |
151
+ | DirectedGraph | 1K addVertex | 0.05 | - | - | - |
152
+ | Stack | 1M push | 46.38 | 30.28 | 1.65 | 32.38 |
153
+
154
+ [//]: # (No deletion!!! End of README Performance Section)
155
+
156
+ šŸ“Š [Full benchmarks →](./docs/PERFORMANCE.md) | [Interactive report →](./docs/benchmark.html)
134
157
 
135
158
  ---
136
159
 
@@ -271,6 +294,10 @@ queue.push(6); // Add to back: O(1)
271
294
  | **Stack** | Undo/redo, expression parsing | O(1) | [npm](https://www.npmjs.com/package/stack-typed) |
272
295
  | **LinkedList** | Dynamic sizing, no index shift | O(1)* | [npm](https://www.npmjs.com/package/linked-list-typed) |
273
296
  | **AVLTree** | Stricter balance than RB-Tree | O(log n) | [npm](https://www.npmjs.com/package/avl-tree-typed) |
297
+ | **SkipList** | Sorted KV, TreeMap alternative | O(log n) avg | — |
298
+ | **SegmentTree** | Range sum/min/max/custom queries | O(log n) | — |
299
+ | **BinaryIndexedTree** | Prefix sums, frequency counting | O(log n) | — |
300
+ | **Matrix** | 2D grid arithmetic | O(n²) add | — |
274
301
 
275
302
  šŸ‘‰ [See all 20+ structures →](./docs/REFERENCE.md)
276
303
 
@@ -526,6 +553,12 @@ Need prefix/text matching?
526
553
  Need graph operations?
527
554
  → DirectedGraph/UndirectedGraph
528
555
 
556
+ Need range queries on array (sum/min/max)?
557
+ → SegmentTree (any merge op) or BinaryIndexedTree (prefix sums only)
558
+
559
+ Need sorted key-value with same API as TreeMap?
560
+ → SkipList (O(log n) avg, probabilistic balancing)
561
+
529
562
  Otherwise?
530
563
  → Use Array (simplest case)
531
564
  ```