data-structure-typed 2.4.5 → 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 (71) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +15 -5
  3. package/dist/cjs/index.cjs +10240 -2079
  4. package/dist/cjs-legacy/index.cjs +10305 -2135
  5. package/dist/esm/index.mjs +10241 -2078
  6. package/dist/esm-legacy/index.mjs +10306 -2134
  7. package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
  8. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +128 -51
  9. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +210 -164
  10. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +429 -78
  11. package/dist/types/data-structures/binary-tree/bst.d.ts +311 -28
  12. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +212 -32
  13. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +218 -152
  14. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1281 -5
  15. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1087 -201
  16. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +858 -65
  17. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1133 -5
  18. package/dist/types/data-structures/graph/directed-graph.d.ts +219 -47
  19. package/dist/types/data-structures/graph/map-graph.d.ts +59 -1
  20. package/dist/types/data-structures/graph/undirected-graph.d.ts +204 -59
  21. package/dist/types/data-structures/hash/hash-map.d.ts +230 -77
  22. package/dist/types/data-structures/heap/heap.d.ts +287 -99
  23. package/dist/types/data-structures/heap/max-heap.d.ts +46 -0
  24. package/dist/types/data-structures/heap/min-heap.d.ts +59 -0
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +286 -44
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +278 -65
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +415 -12
  28. package/dist/types/data-structures/matrix/matrix.d.ts +331 -0
  29. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +57 -0
  30. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +60 -0
  31. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +60 -0
  32. package/dist/types/data-structures/queue/deque.d.ts +272 -65
  33. package/dist/types/data-structures/queue/queue.d.ts +211 -42
  34. package/dist/types/data-structures/stack/stack.d.ts +174 -32
  35. package/dist/types/data-structures/trie/trie.d.ts +213 -43
  36. package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -1
  37. package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +1 -4
  38. package/dist/umd/data-structure-typed.js +10308 -2133
  39. package/dist/umd/data-structure-typed.min.js +4 -4
  40. package/package.json +5 -4
  41. package/src/data-structures/base/iterable-element-base.ts +4 -5
  42. package/src/data-structures/binary-tree/avl-tree.ts +146 -51
  43. package/src/data-structures/binary-tree/binary-indexed-tree.ts +316 -247
  44. package/src/data-structures/binary-tree/binary-tree.ts +454 -79
  45. package/src/data-structures/binary-tree/bst.ts +359 -34
  46. package/src/data-structures/binary-tree/red-black-tree.ts +309 -97
  47. package/src/data-structures/binary-tree/segment-tree.ts +378 -248
  48. package/src/data-structures/binary-tree/tree-map.ts +1403 -6
  49. package/src/data-structures/binary-tree/tree-multi-map.ts +1214 -211
  50. package/src/data-structures/binary-tree/tree-multi-set.ts +954 -65
  51. package/src/data-structures/binary-tree/tree-set.ts +1250 -9
  52. package/src/data-structures/graph/directed-graph.ts +229 -47
  53. package/src/data-structures/graph/map-graph.ts +59 -1
  54. package/src/data-structures/graph/undirected-graph.ts +213 -59
  55. package/src/data-structures/hash/hash-map.ts +241 -77
  56. package/src/data-structures/heap/heap.ts +301 -99
  57. package/src/data-structures/heap/max-heap.ts +46 -0
  58. package/src/data-structures/heap/min-heap.ts +59 -0
  59. package/src/data-structures/linked-list/doubly-linked-list.ts +303 -44
  60. package/src/data-structures/linked-list/singly-linked-list.ts +293 -65
  61. package/src/data-structures/linked-list/skip-linked-list.ts +707 -90
  62. package/src/data-structures/matrix/matrix.ts +424 -12
  63. package/src/data-structures/priority-queue/max-priority-queue.ts +57 -0
  64. package/src/data-structures/priority-queue/min-priority-queue.ts +60 -0
  65. package/src/data-structures/priority-queue/priority-queue.ts +60 -0
  66. package/src/data-structures/queue/deque.ts +287 -65
  67. package/src/data-structures/queue/queue.ts +223 -42
  68. package/src/data-structures/stack/stack.ts +184 -32
  69. package/src/data-structures/trie/trie.ts +225 -43
  70. package/src/types/data-structures/binary-tree/segment-tree.ts +1 -1
  71. package/src/types/data-structures/linked-list/skip-linked-list.ts +2 -1
package/CHANGELOG.md CHANGED
@@ -8,7 +8,7 @@ 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.5](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
12
 
13
13
  ### Changes
14
14
 
package/README.md CHANGED
@@ -139,11 +139,11 @@ for (let i = 0; i < 100000; i++) {
139
139
  | DoublyLinkedList | 100k push | 5.70 | 2.40 | 5.70 | 1.90 |
140
140
  | SinglyLinkedList | 100K unshift & shift | 3.77 | 1958.39 | 4.80 | - |
141
141
  | PriorityQueue | 100K add | 4.00 | - | 1.05 | 4.96 |
142
- | TreeSet | 1M add | 962.76 | - | 462.00 | 640.31 |
143
- | TreeMap | 1M set | 996.95 | - | 512.00 | 624.82 |
144
- | TreeMultiSet | 1M add (TreeMultiSet expanded iteration) | 218.78 | - | 752.00 | - |
145
- | TreeMultiMap | 1M add (TreeMultiMap bucketed) | 387.80 | - | 731.00 | - |
146
- | RedBlackTree | 1M get | 108.02 | - | 52.97 | - |
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
147
  | BST | 10K add randomly | 5.50 | - | - | - |
148
148
  | BinaryTree | 1K add randomly | 9.77 | - | - | - |
149
149
  | HashMap | 1M set | 146.17 | 144.83 | 76.26 | 94.16 |
@@ -294,6 +294,10 @@ queue.push(6); // Add to back: O(1)
294
294
  | **Stack** | Undo/redo, expression parsing | O(1) | [npm](https://www.npmjs.com/package/stack-typed) |
295
295
  | **LinkedList** | Dynamic sizing, no index shift | O(1)* | [npm](https://www.npmjs.com/package/linked-list-typed) |
296
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 | — |
297
301
 
298
302
  👉 [See all 20+ structures →](./docs/REFERENCE.md)
299
303
 
@@ -549,6 +553,12 @@ Need prefix/text matching?
549
553
  Need graph operations?
550
554
  → DirectedGraph/UndirectedGraph
551
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
+
552
562
  Otherwise?
553
563
  → Use Array (simplest case)
554
564
  ```