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.
- package/CHANGELOG.md +1 -1
- package/README.md +15 -5
- package/dist/cjs/index.cjs +10240 -2079
- package/dist/cjs-legacy/index.cjs +10305 -2135
- package/dist/esm/index.mjs +10241 -2078
- package/dist/esm-legacy/index.mjs +10306 -2134
- package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +128 -51
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +210 -164
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +429 -78
- package/dist/types/data-structures/binary-tree/bst.d.ts +311 -28
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +212 -32
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +218 -152
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1281 -5
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1087 -201
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +858 -65
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1133 -5
- package/dist/types/data-structures/graph/directed-graph.d.ts +219 -47
- package/dist/types/data-structures/graph/map-graph.d.ts +59 -1
- package/dist/types/data-structures/graph/undirected-graph.d.ts +204 -59
- package/dist/types/data-structures/hash/hash-map.d.ts +230 -77
- package/dist/types/data-structures/heap/heap.d.ts +287 -99
- package/dist/types/data-structures/heap/max-heap.d.ts +46 -0
- package/dist/types/data-structures/heap/min-heap.d.ts +59 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +286 -44
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +278 -65
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +415 -12
- package/dist/types/data-structures/matrix/matrix.d.ts +331 -0
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +57 -0
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +60 -0
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +60 -0
- package/dist/types/data-structures/queue/deque.d.ts +272 -65
- package/dist/types/data-structures/queue/queue.d.ts +211 -42
- package/dist/types/data-structures/stack/stack.d.ts +174 -32
- package/dist/types/data-structures/trie/trie.d.ts +213 -43
- package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -1
- package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +1 -4
- package/dist/umd/data-structure-typed.js +10308 -2133
- package/dist/umd/data-structure-typed.min.js +4 -4
- package/package.json +5 -4
- package/src/data-structures/base/iterable-element-base.ts +4 -5
- package/src/data-structures/binary-tree/avl-tree.ts +146 -51
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +316 -247
- package/src/data-structures/binary-tree/binary-tree.ts +454 -79
- package/src/data-structures/binary-tree/bst.ts +359 -34
- package/src/data-structures/binary-tree/red-black-tree.ts +309 -97
- package/src/data-structures/binary-tree/segment-tree.ts +378 -248
- package/src/data-structures/binary-tree/tree-map.ts +1403 -6
- package/src/data-structures/binary-tree/tree-multi-map.ts +1214 -211
- package/src/data-structures/binary-tree/tree-multi-set.ts +954 -65
- package/src/data-structures/binary-tree/tree-set.ts +1250 -9
- package/src/data-structures/graph/directed-graph.ts +229 -47
- package/src/data-structures/graph/map-graph.ts +59 -1
- package/src/data-structures/graph/undirected-graph.ts +213 -59
- package/src/data-structures/hash/hash-map.ts +241 -77
- package/src/data-structures/heap/heap.ts +301 -99
- package/src/data-structures/heap/max-heap.ts +46 -0
- package/src/data-structures/heap/min-heap.ts +59 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +303 -44
- package/src/data-structures/linked-list/singly-linked-list.ts +293 -65
- package/src/data-structures/linked-list/skip-linked-list.ts +707 -90
- package/src/data-structures/matrix/matrix.ts +424 -12
- package/src/data-structures/priority-queue/max-priority-queue.ts +57 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +60 -0
- package/src/data-structures/priority-queue/priority-queue.ts +60 -0
- package/src/data-structures/queue/deque.ts +287 -65
- package/src/data-structures/queue/queue.ts +223 -42
- package/src/data-structures/stack/stack.ts +184 -32
- package/src/data-structures/trie/trie.ts +225 -43
- package/src/types/data-structures/binary-tree/segment-tree.ts +1 -1
- 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.
|
|
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 |
|
|
143
|
-
| TreeMap | 1M set |
|
|
144
|
-
| TreeMultiSet | 1M add (TreeMultiSet expanded iteration) |
|
|
145
|
-
| TreeMultiMap | 1M add (TreeMultiMap bucketed) |
|
|
146
|
-
| RedBlackTree | 1M get |
|
|
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
|
```
|