data-structure-typed 1.50.1 → 1.50.3
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 +2 -1
- package/README.md +30 -28
- package/README_zh-CN.md +1 -1
- package/SPECIFICATION.md +56 -0
- package/SPONSOR-zh-CN.md +90 -0
- package/SPONSOR.md +54 -0
- package/benchmark/report.html +13 -13
- package/benchmark/report.json +149 -161
- package/dist/cjs/data-structures/base/iterable-base.d.ts +120 -9
- package/dist/cjs/data-structures/base/iterable-base.js +143 -7
- package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +72 -47
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +101 -72
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +244 -199
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +484 -376
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +92 -79
- package/dist/cjs/data-structures/binary-tree/bst.js +68 -76
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +127 -57
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +152 -99
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
- package/dist/cjs/data-structures/binary-tree/segment-tree.js +127 -10
- package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +72 -58
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js +102 -85
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.d.ts +1 -78
- package/dist/cjs/data-structures/graph/abstract-graph.js +3 -189
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.d.ts +73 -0
- package/dist/cjs/data-structures/graph/directed-graph.js +131 -0
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/map-graph.d.ts +8 -0
- package/dist/cjs/data-structures/graph/map-graph.js +14 -0
- package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.d.ts +76 -7
- package/dist/cjs/data-structures/graph/undirected-graph.js +151 -18
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +254 -28
- package/dist/cjs/data-structures/hash/hash-map.js +347 -78
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.d.ts +95 -25
- package/dist/cjs/data-structures/heap/heap.js +95 -26
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +126 -63
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +141 -77
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +154 -106
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +164 -115
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +63 -36
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js +63 -36
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/matrix/matrix.d.ts +35 -4
- package/dist/cjs/data-structures/matrix/matrix.js +50 -11
- package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +10 -0
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +11 -0
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
- package/dist/cjs/data-structures/priority-queue/priority-queue.js +8 -0
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +139 -35
- package/dist/cjs/data-structures/queue/deque.js +200 -62
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +103 -49
- package/dist/cjs/data-structures/queue/queue.js +111 -49
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/stack/stack.d.ts +51 -21
- package/dist/cjs/data-structures/stack/stack.js +58 -22
- package/dist/cjs/data-structures/stack/stack.js.map +1 -1
- package/dist/cjs/data-structures/tree/tree.d.ts +57 -3
- package/dist/cjs/data-structures/tree/tree.js +77 -11
- package/dist/cjs/data-structures/tree/tree.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.d.ts +135 -34
- package/dist/cjs/data-structures/trie/trie.js +153 -33
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/cjs/types/data-structures/hash/hash-map.d.ts +4 -3
- package/dist/cjs/types/utils/utils.d.ts +1 -0
- package/dist/mjs/data-structures/base/iterable-base.d.ts +120 -9
- package/dist/mjs/data-structures/base/iterable-base.js +143 -7
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +72 -47
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +102 -73
- package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
- package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +244 -199
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +483 -375
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +92 -79
- package/dist/mjs/data-structures/binary-tree/bst.js +68 -76
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +127 -57
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +153 -100
- package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
- package/dist/mjs/data-structures/binary-tree/segment-tree.js +127 -10
- package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +72 -58
- package/dist/mjs/data-structures/binary-tree/tree-multimap.js +102 -86
- package/dist/mjs/data-structures/graph/abstract-graph.d.ts +1 -78
- package/dist/mjs/data-structures/graph/abstract-graph.js +3 -188
- package/dist/mjs/data-structures/graph/directed-graph.d.ts +73 -0
- package/dist/mjs/data-structures/graph/directed-graph.js +131 -0
- package/dist/mjs/data-structures/graph/map-graph.d.ts +8 -0
- package/dist/mjs/data-structures/graph/map-graph.js +14 -0
- package/dist/mjs/data-structures/graph/undirected-graph.d.ts +76 -7
- package/dist/mjs/data-structures/graph/undirected-graph.js +152 -19
- package/dist/mjs/data-structures/hash/hash-map.d.ts +254 -28
- package/dist/mjs/data-structures/hash/hash-map.js +353 -84
- package/dist/mjs/data-structures/heap/heap.d.ts +95 -25
- package/dist/mjs/data-structures/heap/heap.js +95 -26
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +126 -63
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +144 -80
- package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +154 -106
- package/dist/mjs/data-structures/linked-list/singly-linked-list.js +166 -117
- package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +63 -36
- package/dist/mjs/data-structures/linked-list/skip-linked-list.js +63 -36
- package/dist/mjs/data-structures/matrix/matrix.d.ts +35 -4
- package/dist/mjs/data-structures/matrix/matrix.js +50 -11
- package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
- package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +10 -0
- package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
- package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +11 -0
- package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
- package/dist/mjs/data-structures/priority-queue/priority-queue.js +8 -0
- package/dist/mjs/data-structures/queue/deque.d.ts +139 -35
- package/dist/mjs/data-structures/queue/deque.js +205 -67
- package/dist/mjs/data-structures/queue/queue.d.ts +103 -49
- package/dist/mjs/data-structures/queue/queue.js +111 -49
- package/dist/mjs/data-structures/stack/stack.d.ts +51 -21
- package/dist/mjs/data-structures/stack/stack.js +58 -22
- package/dist/mjs/data-structures/tree/tree.d.ts +57 -3
- package/dist/mjs/data-structures/tree/tree.js +80 -14
- package/dist/mjs/data-structures/trie/trie.d.ts +135 -34
- package/dist/mjs/data-structures/trie/trie.js +156 -36
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/mjs/types/data-structures/hash/hash-map.d.ts +4 -3
- package/dist/mjs/types/utils/utils.d.ts +1 -0
- package/dist/umd/data-structure-typed.js +3121 -1583
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +61 -55
- package/src/data-structures/base/iterable-base.ts +184 -19
- package/src/data-structures/binary-tree/avl-tree.ts +134 -100
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
- package/src/data-structures/binary-tree/binary-tree.ts +674 -671
- package/src/data-structures/binary-tree/bst.ts +127 -136
- package/src/data-structures/binary-tree/rb-tree.ts +199 -166
- package/src/data-structures/binary-tree/segment-tree.ts +145 -11
- package/src/data-structures/binary-tree/tree-multimap.ts +138 -115
- package/src/data-structures/graph/abstract-graph.ts +4 -211
- package/src/data-structures/graph/directed-graph.ts +152 -0
- package/src/data-structures/graph/map-graph.ts +15 -0
- package/src/data-structures/graph/undirected-graph.ts +171 -19
- package/src/data-structures/hash/hash-map.ts +389 -96
- package/src/data-structures/heap/heap.ts +97 -26
- package/src/data-structures/linked-list/doubly-linked-list.ts +156 -83
- package/src/data-structures/linked-list/singly-linked-list.ts +174 -120
- package/src/data-structures/linked-list/skip-linked-list.ts +63 -37
- package/src/data-structures/matrix/matrix.ts +52 -12
- package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
- package/src/data-structures/priority-queue/priority-queue.ts +8 -0
- package/src/data-structures/queue/deque.ts +225 -70
- package/src/data-structures/queue/queue.ts +118 -49
- package/src/data-structures/stack/stack.ts +63 -23
- package/src/data-structures/tree/tree.ts +89 -15
- package/src/data-structures/trie/trie.ts +173 -38
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/hash/hash-map.ts +4 -3
- package/src/types/utils/utils.ts +2 -0
- package/test/performance/data-structures/graph/directed-graph.test.ts +4 -4
- package/test/performance/data-structures/queue/deque.test.ts +26 -25
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +37 -0
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +46 -17
- package/test/unit/data-structures/binary-tree/bst.test.ts +65 -1
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +38 -1
- package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +37 -32
- package/test/unit/data-structures/graph/abstract-graph.test.ts +11 -0
- package/test/unit/data-structures/graph/directed-graph.test.ts +190 -5
- package/test/unit/data-structures/graph/undirected-graph.test.ts +263 -18
- package/test/unit/data-structures/hash/hash-map.test.ts +376 -353
- package/test/unit/data-structures/heap/heap.test.ts +18 -1
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +24 -5
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +20 -2
- package/test/unit/data-structures/linked-list/skip-list.test.ts +1 -1
- package/test/unit/data-structures/queue/deque.test.ts +65 -5
- package/test/unit/data-structures/queue/queue.test.ts +24 -5
- package/test/unit/data-structures/stack/stack.test.ts +17 -0
- package/test/unit/data-structures/trie/trie.test.ts +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -8,10 +8,11 @@ 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
|
-
## [v1.50.
|
|
11
|
+
## [v1.50.3](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming)
|
|
12
12
|
|
|
13
13
|
### Changes
|
|
14
14
|
|
|
15
|
+
- Tests for DirectedGraph.tarjan [`#69`](https://github.com/zrwusa/data-structure-typed/pull/69)
|
|
15
16
|
- Rbtree [`#31`](https://github.com/zrwusa/data-structure-typed/pull/31)
|
|
16
17
|
- [graph test] edge cases enriched [`#30`](https://github.com/zrwusa/data-structure-typed/pull/30)
|
|
17
18
|
- [graph] Modify the data structure design of the graph to change the g… [`#29`](https://github.com/zrwusa/data-structure-typed/pull/29)
|
package/README.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# data-structure-typed
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|

|
|
5
|
+

|
|
5
6
|

|
|
6
7
|

|
|
7
8
|

|
|
8
9
|

|
|
9
10
|

|
|
11
|
+

|
|
10
12
|
|
|
11
13
|
[//]: # ()
|
|
12
14
|
|
|
@@ -38,58 +40,58 @@ Heap, Binary Tree, Red Black Tree, Linked List, Deque, Trie, Directed Graph, Und
|
|
|
38
40
|
<thead>
|
|
39
41
|
<tr>
|
|
40
42
|
<th>Method</th>
|
|
41
|
-
<th>Time Taken
|
|
42
|
-
<th>Scale</th>
|
|
43
|
+
<th>Time Taken</th>
|
|
44
|
+
<th>Data Scale</th>
|
|
43
45
|
<th>Belongs To</th>
|
|
44
|
-
<th>
|
|
46
|
+
<th>Complexity</th>
|
|
45
47
|
</tr>
|
|
46
48
|
</thead>
|
|
47
49
|
<tbody>
|
|
48
50
|
<tr>
|
|
49
51
|
<td>Queue.push & shift</td>
|
|
50
|
-
<td>5.83</td>
|
|
52
|
+
<td>5.83 ms</td>
|
|
51
53
|
<td>100,000</td>
|
|
52
|
-
<td>
|
|
54
|
+
<td>Ours</td>
|
|
53
55
|
<td>O(1)</td>
|
|
54
56
|
</tr>
|
|
55
57
|
<tr>
|
|
56
58
|
<td>Array.push & shift</td>
|
|
57
|
-
<td>2829.59</td>
|
|
59
|
+
<td>2829.59 ms</td>
|
|
58
60
|
<td>100,000</td>
|
|
59
61
|
<td>Native JS</td>
|
|
60
62
|
<td>O(n)</td>
|
|
61
63
|
</tr>
|
|
62
64
|
<tr>
|
|
63
65
|
<td>Deque.unshift & shift</td>
|
|
64
|
-
<td>2.44</td>
|
|
66
|
+
<td>2.44 ms</td>
|
|
65
67
|
<td>100,000</td>
|
|
66
|
-
<td>
|
|
68
|
+
<td>Ours</td>
|
|
67
69
|
<td>O(1)</td>
|
|
68
70
|
</tr>
|
|
69
71
|
<tr>
|
|
70
72
|
<td>Array.unshift & shift</td>
|
|
71
|
-
<td>4750.37</td>
|
|
73
|
+
<td>4750.37 ms</td>
|
|
72
74
|
<td>100,000</td>
|
|
73
75
|
<td>Native JS</td>
|
|
74
76
|
<td>O(n)</td>
|
|
75
77
|
</tr>
|
|
76
78
|
<tr>
|
|
77
79
|
<td>HashMap.set</td>
|
|
78
|
-
<td>122.51</td>
|
|
80
|
+
<td>122.51 ms</td>
|
|
79
81
|
<td>1,000,000</td>
|
|
80
|
-
<td>
|
|
82
|
+
<td>Ours</td>
|
|
81
83
|
<td>O(1)</td>
|
|
82
84
|
</tr>
|
|
83
85
|
<tr>
|
|
84
86
|
<td>Map.set</td>
|
|
85
|
-
<td>223.80</td>
|
|
87
|
+
<td>223.80 ms</td>
|
|
86
88
|
<td>1,000,000</td>
|
|
87
89
|
<td>Native JS</td>
|
|
88
90
|
<td>O(1)</td>
|
|
89
91
|
</tr>
|
|
90
92
|
<tr>
|
|
91
93
|
<td>Set.add</td>
|
|
92
|
-
<td>185.06</td>
|
|
94
|
+
<td>185.06 ms</td>
|
|
93
95
|
<td>1,000,000</td>
|
|
94
96
|
<td>Native JS</td>
|
|
95
97
|
<td>O(1)</td>
|
|
@@ -852,7 +854,7 @@ Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.key) // ['A', 'B', '
|
|
|
852
854
|
<td>Recursion</td>
|
|
853
855
|
</tr>
|
|
854
856
|
<tr>
|
|
855
|
-
<td>Graph
|
|
857
|
+
<td>Graph getCutVertices</td>
|
|
856
858
|
<td>Find cut vertices in a graph, which are nodes that, when removed, increase the number of connected components in
|
|
857
859
|
the graph.
|
|
858
860
|
</td>
|
|
@@ -939,43 +941,43 @@ We strictly adhere to computer science theory and software development standards
|
|
|
939
941
|
[//]: # (No deletion!!! Start of Replace Section)
|
|
940
942
|
<div class="json-to-html-collapse clearfix 0">
|
|
941
943
|
<div class='collapsible level0' ><span class='json-to-html-label'>avl-tree</span></div>
|
|
942
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 add randomly</td><td>
|
|
944
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 add randomly</td><td>125.60</td><td>7.96</td><td>0.00</td></tr><tr><td>10,000 add & delete randomly</td><td>181.22</td><td>5.52</td><td>0.00</td></tr><tr><td>10,000 addMany</td><td>134.12</td><td>7.46</td><td>0.01</td></tr><tr><td>10,000 get</td><td>55.08</td><td>18.16</td><td>0.01</td></tr></table></div>
|
|
943
945
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
944
946
|
<div class='collapsible level0' ><span class='json-to-html-label'>binary-tree-overall</span></div>
|
|
945
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 RBTree add</td><td>
|
|
947
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 RBTree add</td><td>6.17</td><td>161.95</td><td>0.00</td></tr><tr><td>10,000 RBTree add & delete randomly</td><td>16.07</td><td>62.22</td><td>2.62e-4</td></tr><tr><td>10,000 RBTree get</td><td>19.86</td><td>50.36</td><td>2.44e-4</td></tr><tr><td>10,000 AVLTree add</td><td>134.38</td><td>7.44</td><td>0.02</td></tr><tr><td>10,000 AVLTree add & delete randomly</td><td>207.20</td><td>4.83</td><td>0.06</td></tr><tr><td>10,000 AVLTree get</td><td>0.98</td><td>1015.54</td><td>2.73e-5</td></tr></table></div>
|
|
946
948
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
947
949
|
<div class='collapsible level0' ><span class='json-to-html-label'>rb-tree</span></div>
|
|
948
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>
|
|
950
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>86.65</td><td>11.54</td><td>0.02</td></tr><tr><td>100,000 add & delete randomly</td><td>221.02</td><td>4.52</td><td>0.03</td></tr><tr><td>100,000 getNode</td><td>190.54</td><td>5.25</td><td>0.00</td></tr><tr><td>100,000 add & iterator</td><td>122.10</td><td>8.19</td><td>0.01</td></tr></table></div>
|
|
949
951
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
950
952
|
<div class='collapsible level0' ><span class='json-to-html-label'>directed-graph</span></div>
|
|
951
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000 addVertex</td><td>0.
|
|
953
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000 addVertex</td><td>0.11</td><td>8896.51</td><td>2.63e-5</td></tr><tr><td>1,000 addEdge</td><td>6.53</td><td>153.21</td><td>0.00</td></tr><tr><td>1,000 getVertex</td><td>0.05</td><td>2.08e+4</td><td>1.06e-5</td></tr><tr><td>1,000 getEdge</td><td>27.53</td><td>36.33</td><td>0.01</td></tr><tr><td>tarjan</td><td>224.53</td><td>4.45</td><td>0.01</td></tr><tr><td>topologicalSort</td><td>184.02</td><td>5.43</td><td>0.00</td></tr></table></div>
|
|
952
954
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
953
955
|
<div class='collapsible level0' ><span class='json-to-html-label'>hash-map</span></div>
|
|
954
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 set</td><td>
|
|
956
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 set</td><td>126.27</td><td>7.92</td><td>0.05</td></tr><tr><td>Native Map 1,000,000 set</td><td>229.80</td><td>4.35</td><td>0.03</td></tr><tr><td>Native Set 1,000,000 add</td><td>175.83</td><td>5.69</td><td>0.01</td></tr><tr><td>1,000,000 set & get</td><td>121.34</td><td>8.24</td><td>0.03</td></tr><tr><td>Native Map 1,000,000 set & get</td><td>290.80</td><td>3.44</td><td>0.03</td></tr><tr><td>Native Set 1,000,000 add & has</td><td>180.71</td><td>5.53</td><td>0.01</td></tr><tr><td>1,000,000 ObjKey set & get</td><td>357.68</td><td>2.80</td><td>0.07</td></tr><tr><td>Native Map 1,000,000 ObjKey set & get</td><td>310.57</td><td>3.22</td><td>0.06</td></tr><tr><td>Native Set 1,000,000 ObjKey add & has</td><td>278.42</td><td>3.59</td><td>0.05</td></tr></table></div>
|
|
955
957
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
956
958
|
<div class='collapsible level0' ><span class='json-to-html-label'>heap</span></div>
|
|
957
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add & poll</td><td>
|
|
959
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add & poll</td><td>24.85</td><td>40.24</td><td>0.00</td></tr><tr><td>100,000 add & dfs</td><td>33.14</td><td>30.17</td><td>0.00</td></tr><tr><td>10,000 fib add & pop</td><td>366.11</td><td>2.73</td><td>0.00</td></tr></table></div>
|
|
958
960
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
959
961
|
<div class='collapsible level0' ><span class='json-to-html-label'>doubly-linked-list</span></div>
|
|
960
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>
|
|
962
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>217.98</td><td>4.59</td><td>0.07</td></tr><tr><td>1,000,000 unshift</td><td>223.20</td><td>4.48</td><td>0.08</td></tr><tr><td>1,000,000 unshift & shift</td><td>172.87</td><td>5.78</td><td>0.03</td></tr><tr><td>1,000,000 addBefore</td><td>387.13</td><td>2.58</td><td>0.20</td></tr></table></div>
|
|
961
963
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
962
964
|
<div class='collapsible level0' ><span class='json-to-html-label'>singly-linked-list</span></div>
|
|
963
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push & shift</td><td>
|
|
965
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push & shift</td><td>225.13</td><td>4.44</td><td>0.07</td></tr><tr><td>10,000 push & pop</td><td>234.54</td><td>4.26</td><td>0.02</td></tr><tr><td>10,000 addBefore</td><td>252.62</td><td>3.96</td><td>0.00</td></tr></table></div>
|
|
964
966
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
965
967
|
<div class='collapsible level0' ><span class='json-to-html-label'>priority-queue</span></div>
|
|
966
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add & poll</td><td>
|
|
968
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add & poll</td><td>76.49</td><td>13.07</td><td>0.00</td></tr></table></div>
|
|
967
969
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
968
970
|
<div class='collapsible level0' ><span class='json-to-html-label'>deque</span></div>
|
|
969
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>13.
|
|
971
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>13.20</td><td>75.75</td><td>2.79e-4</td></tr><tr><td>1,000,000 push & pop</td><td>22.21</td><td>45.03</td><td>3.27e-4</td></tr><tr><td>100,000 push & shift</td><td>2.26</td><td>442.24</td><td>1.43e-4</td></tr><tr><td>Native Array 100,000 push & shift</td><td>2329.51</td><td>0.43</td><td>0.10</td></tr><tr><td>100,000 unshift & shift</td><td>2.16</td><td>463.83</td><td>8.20e-5</td></tr><tr><td>Native Array 100,000 unshift & shift</td><td>4590.64</td><td>0.22</td><td>0.33</td></tr></table></div>
|
|
970
972
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
971
973
|
<div class='collapsible level0' ><span class='json-to-html-label'>queue</span></div>
|
|
972
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>
|
|
974
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>49.92</td><td>20.03</td><td>0.02</td></tr><tr><td>100,000 push & shift</td><td>5.07</td><td>197.28</td><td>5.86e-4</td></tr><tr><td>Native Array 100,000 push & shift</td><td>2315.78</td><td>0.43</td><td>0.13</td></tr><tr><td>Native Array 100,000 push & pop</td><td>4.37</td><td>228.72</td><td>1.32e-4</td></tr></table></div>
|
|
973
975
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
974
976
|
<div class='collapsible level0' ><span class='json-to-html-label'>stack</span></div>
|
|
975
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>
|
|
977
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>44.50</td><td>22.47</td><td>0.01</td></tr><tr><td>1,000,000 push & pop</td><td>53.57</td><td>18.67</td><td>0.02</td></tr></table></div>
|
|
976
978
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
977
979
|
<div class='collapsible level0' ><span class='json-to-html-label'>trie</span></div>
|
|
978
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 push</td><td>
|
|
980
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 push</td><td>42.95</td><td>23.28</td><td>6.68e-4</td></tr><tr><td>100,000 getWords</td><td>92.11</td><td>10.86</td><td>0.01</td></tr></table></div>
|
|
979
981
|
</div>
|
|
980
982
|
|
|
981
983
|
[//]: # (No deletion!!! End of Replace Section)
|
package/README_zh-CN.md
CHANGED
package/SPECIFICATION.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
[NPM](https://www.npmjs.com/package/data-structure-typed)
|
|
3
|
+
|
|
4
|
+
[Github](https://github.com/zrwusa/data-structure-typed)
|
|
5
|
+
|
|
6
|
+
## Pain Points Addressed
|
|
7
|
+
|
|
8
|
+
### Enhancing the Performance of Simulated Data Structures in JS/TS
|
|
9
|
+
|
|
10
|
+
- `Queue`: While many resort to using Arrays to simulate Queues and Deques, the time complexity of Array.shift is O(n). We have tackled this challenge by implementing a Queue and Deque with O(1) time complexity for enqueue and dequeue operations.
|
|
11
|
+
|
|
12
|
+
- `HashMap`: Opting for a pure HashMap over the built-in Map (technically a LinkedHashMap) can boost algorithmic speed. However, the performance is compromised due to the necessity of considering insertion order. We have independently implemented an optimized HashMap.
|
|
13
|
+
|
|
14
|
+
- `Stack`: In JS, simulating a Stack with an Array is acceptable, and its performance is on par with a genuine Stack.
|
|
15
|
+
|
|
16
|
+
### Introducing Missing Native Data Structures in JS/TS
|
|
17
|
+
|
|
18
|
+
- `Heap / Priority Queue`: Algorithms with O(log n) time complexity have been pivotal in improving efficiency since the dawn of computers. A Heap supports insertion, deletion, and search with O(log n) time complexity, coupled with the ability to obtain the minimum / maximum value in O(1) time.
|
|
19
|
+
|
|
20
|
+
- `Red Black Tree`: Developers well-versed in databases, file systems, Linux virtual memory management, and network routing tables often have a nuanced understanding of Red-Black Trees. It stands out as the least operation-intensive among all balanced binary search trees, offering optimal performance balance in CRUD operations.
|
|
21
|
+
|
|
22
|
+
- `Linked List`: In scenarios where insertion or deletion of elements with O(1) time complexity is required at a specific index in an ordered collection, JS lacks a provided data structure. Hence, the need for a LinkedList to implement this functionality.
|
|
23
|
+
|
|
24
|
+
- `Trie`: Efficient for fast string queries and space-efficient string storage, yet not commonly found in the standard libraries of most programming languages.
|
|
25
|
+
|
|
26
|
+
- `Graph`: This data structure is not commonly found in the standard libraries of most languages, making it a non-issue in JS.
|
|
27
|
+
|
|
28
|
+
## Advantages
|
|
29
|
+
|
|
30
|
+
### Performance:
|
|
31
|
+
|
|
32
|
+
- The performance of some ours data structures has surpassed JS's built-in data structures (`Queue`, `Deque`, `HashMap`), while most are comparable to or even surpass those in other languages. Some are still undergoing refinement (`Graph`, `AVL Tree`).
|
|
33
|
+
|
|
34
|
+
### Uniformity
|
|
35
|
+
|
|
36
|
+
- 1. Implementation or constraint of `forEach`, `filter`, `map`, `every`, `some`, `reduce`, `find`, `has`, `hasValue`, `get`, `print`, `isEmpty`, `clear`, `clone` methods in the base class.
|
|
37
|
+
- 2. Use of generators to uniformly implement `[Symbol.iterator]`, `entries`, `keys`, `values`. Delaying iterator execution prevents performance loss and provides control during traversal.
|
|
38
|
+
- 3. All deletion methods uniformly use the widely adopted `delete` in ES6, while addition methods uniformly use `add`. Compatibility with some specifications in Java.
|
|
39
|
+
- 4. The first parameter for all constructors is data, and the second parameter is configuration, maintaining uniformity. The first parameter accepts any iterable type for seamless conversion between data structures.
|
|
40
|
+
- 5. Uniform return types, for example, the `add` method consistently returns a boolean.
|
|
41
|
+
|
|
42
|
+
### Convenience and Simplicity of APIs
|
|
43
|
+
|
|
44
|
+
- Inspired by ES6, Java, ESNext, TypeScript, Python, featuring methods like `forEach`, `filter`, `map`, `every`, `some`, `reduce`, `find`, `has`, `hasValue` and `get`.
|
|
45
|
+
|
|
46
|
+
### Use of Commonly Understood Industry Standard Naming
|
|
47
|
+
|
|
48
|
+
- `enqueue`, `dequeue`, `push`, `pop`, `poll`, `addLast`, `addFirst`, `pollFirst`, `pollLast`, `isEmpty`, `clear`, `print`, `clone`.
|
|
49
|
+
|
|
50
|
+
### Implementation of Customizable Features Whenever Possible
|
|
51
|
+
|
|
52
|
+
- Such as providing callback functions (lambda expressions) for all traversal methods.
|
|
53
|
+
|
|
54
|
+
### Comprehensive Documentation
|
|
55
|
+
|
|
56
|
+
- The documentation not only explains the purpose of methods but also annotates time and space complexity across the entire series.
|
package/SPONSOR-zh-CN.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
|
|
2
|
+
# 我是谁
|
|
3
|
+
|
|
4
|
+
我是一个拥有15年工作经验的软件开发工程师,自大学毕业职于不同行业的软件公司其中也包括一些大厂。
|
|
5
|
+
|
|
6
|
+
# 目前现状
|
|
7
|
+
|
|
8
|
+
为了孩子得到正规教育移居到马来西亚,持有10年居留签证,但是这个签证不允许我被马来西亚公司雇佣。
|
|
9
|
+
由于自己酷爱编程,又正逢JavaScript / TypeScript (以下简称`JS/TS`)没有标准库涵盖数据结构,便决定在开源社区自己实现一套数据结构 [data-structure-typed]()。
|
|
10
|
+
|
|
11
|
+
[NPM](https://www.npmjs.com/package/data-structure-typed)
|
|
12
|
+
|
|
13
|
+
[Github](https://github.com/zrwusa/data-structure-typed)
|
|
14
|
+
|
|
15
|
+
# 项目介绍
|
|
16
|
+
|
|
17
|
+
## 最终目标
|
|
18
|
+
|
|
19
|
+
- 成为JS/TS的标准库的一部分。
|
|
20
|
+
|
|
21
|
+
## 解决了的痛点
|
|
22
|
+
|
|
23
|
+
### 在JS / TS我们只能基于Array和Map来模拟一些数据结构,例如Queue,Deque,Stack,HashMap
|
|
24
|
+
|
|
25
|
+
- `Queue`:大家使用Array来模拟Queue和Deque,但是Array.shift方法的时间复杂度是O(n)的。我们实现了入队和出队时间复杂度为O(1)的Queue,Deque。
|
|
26
|
+
|
|
27
|
+
- `HashMap`:如大家希望使用一个纯正的HashMap来加速自己的算法,而不是使用内置的Map(严格来说是LinkedHashMap),由于需要顾及插入顺序所以性能上逊色于纯正的HashMap。我们单独实现了HashMap
|
|
28
|
+
|
|
29
|
+
- `Stack`: 在JS中,用Array模拟Stack并没有什么不妥,性能也不弱于真正的Stack。
|
|
30
|
+
|
|
31
|
+
### JS / TS内置数据结构的缺失。
|
|
32
|
+
|
|
33
|
+
- `Heap / Priority Queue`:
|
|
34
|
+
不得不提O(log n),这个算法时间复杂度是人类使用计算机以来最受欢迎的提高效率的方式。Heap本身就支持插入、删除、查找时间复杂度均为O(log n),
|
|
35
|
+
还顺带附赠一个动态随时以O(1)的时间复杂度获取最值的功能。
|
|
36
|
+
|
|
37
|
+
- `Red Black Tree`:
|
|
38
|
+
相信很多了解数据库、文件系统、Linux的虚拟内存管理和网络路由表底层的开发者都对红黑树有一定了解。
|
|
39
|
+
因为它是在所有平衡二叉搜索树中操作消耗量最少的,而且在CRUD这4个操作上性能平衡得最好的实现。
|
|
40
|
+
|
|
41
|
+
- `Linked List`:
|
|
42
|
+
例如我们需要在一个有序集合中,如果已经获取到某个元素的索引的情况下,在这个索引处插入或者删除元素,JS没有提供类似数据结构。我们需要LinkedList来实现。
|
|
43
|
+
|
|
44
|
+
- `Trie`:
|
|
45
|
+
字符串高速查询,字符串存储高效性方面有奇效,但是大多数编程语言的标准库中不常见。
|
|
46
|
+
|
|
47
|
+
- `Graph`:
|
|
48
|
+
这个数据结构在大多数的语言标准库中也不常见,所以我们不把它作为JS的弱项。
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## 优势
|
|
52
|
+
|
|
53
|
+
### 性能:
|
|
54
|
+
|
|
55
|
+
- 少部分数据结构的性能已经超越JS内置数据结构(`Queue`,`Deque`, `HashMap`), 大部分已接近或超越其它语言,部分还没达标(`Graph`, `AVL Tree`)
|
|
56
|
+
|
|
57
|
+
### 统一性
|
|
58
|
+
|
|
59
|
+
- 1、在基类中实现或约束 `forEach`,`filter`, `map`,`every`,`some`,`reduce`,`find`,`has`,`hasValue`,`get`,`print`,`isEmpty`, `clear`,`clone` 方法。
|
|
60
|
+
- 2、使用生成器,统一实现`[Symbol.iterator]`,`entries`, `keys`, `values`。延迟执行遍历器以防止性能损失,并提供遍历时的可控性。
|
|
61
|
+
- 3、所有的删除方法都统一采用ES6标准中惯用的`delete`。添加方法统一使用`add`。同时兼容Java中的一些规范。
|
|
62
|
+
- 4、所有构造函数的第一个参数都是数据,第二个参数是配置,保持统一。第一个参数接受任意可遍历类型,以实现数据结构间自由转换。
|
|
63
|
+
- 5、统一返回参数类型,如`add`方法统一返回布尔值。
|
|
64
|
+
|
|
65
|
+
### APIs的便捷性和简洁性
|
|
66
|
+
|
|
67
|
+
- 受ES6, Java, ESNext, TypeScript, Python的启发,如`forEach`,`filter`, `map`,`every`,`some`,`reduce`,`find`,`has`,`hasValue`,`get`
|
|
68
|
+
|
|
69
|
+
### 使用通俗易懂业界常用命名
|
|
70
|
+
|
|
71
|
+
- `enqueue`, `dequeue`, `push`, `pop`, `poll`, `addLast`, `addFirst`, `pollFirst`, `pollLast`, `isEmpty`, `clear`, `print`, `clone`
|
|
72
|
+
|
|
73
|
+
### 尽量实现可定制化功能
|
|
74
|
+
|
|
75
|
+
- 如所有遍历方法都提供回调函数(拉姆达表达式)的设计
|
|
76
|
+
|
|
77
|
+
### 完善的文档
|
|
78
|
+
|
|
79
|
+
- 文档不但阐述方法的用途,而且全系标注时间和空间复杂度
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
## 社区活跃度
|
|
83
|
+
|
|
84
|
+
- 从社区来说,NPM下载量,
|
|
85
|
+
GitHub星星
|
|
86
|
+
贡献者
|
|
87
|
+
|
|
88
|
+
## 赞助我们吧
|
|
89
|
+
|
|
90
|
+
- 以软件工程标准来说,我们的项目目前已经达到至少75%的完整度,我们相信我们在您的赞助下很快将这个项目的完成度提高到95%,这对我的家庭来说算一种援助,对我们项目组来说是一种鼓励,也希望尽早能够实现成为`JS/TS`标准库的目标。
|
package/SPONSOR.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Who am I
|
|
2
|
+
|
|
3
|
+
I am a seasoned software development engineer with 15 years of professional experience. Following my graduation from university, I have contributed my expertise to various software companies across diverse industries, including some prominent ones.
|
|
4
|
+
|
|
5
|
+
Of course, I have my flaws, I have a nerd-like attitude towards technology and could be described as a perfectionist. For instance, being excessively serious and having a penchant for studying the essence of things, I sometimes come across as a stern boss, which can be intimidating to my wife and daughter.
|
|
6
|
+
|
|
7
|
+
Fortunately, my outlook on life is broad-minded. when it comes to life and family, the keywords are love, loyalty, and appreciation of beauty. I also enjoy studying cultural differences in various regions. Deep down, I actually have a bit of an artistic flair. LOL, just writing this makes me want to laugh!
|
|
8
|
+
|
|
9
|
+
# Current Situation
|
|
10
|
+
|
|
11
|
+
My recent move to Malaysia was motivated by the desire to provide my daughter with a formal education(Yes, you read it correctly, it is the word 'formal', because the education system in some countries is not normal), and it comes alongside holding a 10-year residency visa(MM2H). However, this visa restricts my employment opportunities within Malaysian companies. Fueled by my passion for programming and recognizing the absence of a standardized data structures library in JavaScript/TypeScript, I embarked on the journey of implementing my own set of data structures - `data-structure-typed` within the open-source community.
|
|
12
|
+
|
|
13
|
+
# `data-structure-typed` Project Overview
|
|
14
|
+
|
|
15
|
+
## Ultimate Goal
|
|
16
|
+
|
|
17
|
+
- To seamlessly integrate into the standard library of JS/TS.
|
|
18
|
+
|
|
19
|
+
## Pain Points Addressed
|
|
20
|
+
|
|
21
|
+
### Enhanced the Performance of Simulated Data Structures in JS/TS
|
|
22
|
+
|
|
23
|
+
- `Queue`: While many resort to using Array to simulate Queue and Deque, the time complexity of Array.shift is O(n). We have tackled this by implementing a Queue and Deque with O(1) time complexity.
|
|
24
|
+
|
|
25
|
+
- `HashMap`: The built-in Map in JS is actually a LinkedHashMap, as it maintains the insertion order of elements, resulting in performance inferiority compared to a pure HashMap. We have implemented a pure HashMap.
|
|
26
|
+
|
|
27
|
+
### Introducing Missing Native Data Structures in JS/TS
|
|
28
|
+
|
|
29
|
+
- `Heap / Priority Queue`: Algorithms with O(log n) time complexity have been pivotal in improving efficiency since the dawn of computers. A Heap supports insertion, deletion, and search with O(log n) time complexity, coupled with the ability to obtain the minimum / maximum value in O(1) time.
|
|
30
|
+
|
|
31
|
+
- `Red Black Tree`: Developers well-versed in databases, file systems, Linux virtual memory management, and network routing tables often have a nuanced understanding of Red-Black Trees. It stands out as the least operation-intensive among all balanced binary search trees, offering optimal performance balance in CRUD operations.
|
|
32
|
+
|
|
33
|
+
## Advantages
|
|
34
|
+
|
|
35
|
+
### Performance:
|
|
36
|
+
|
|
37
|
+
- The performance of some ours data structures has surpassed JS's built-in data structures, such as `Queue`, `Deque` and `HashMap`, while most are comparable to or even surpass those in other languages. Some are still undergoing refinement, notably the `Graph` and `AVL Tree`.
|
|
38
|
+
|
|
39
|
+
### Uniformity
|
|
40
|
+
|
|
41
|
+
- 1. Concise and industry-standard naming:Implementation or constraint of `forEach`, `filter`, `map`, `every`, `some`, `reduce`, `find`, `has`, `hasValue`, `get`, `print`, `isEmpty`, `clear`, `clone` methods in the base class.
|
|
42
|
+
- 2. Adhere to the ES6 specification: Use of generators to uniformly implement `[Symbol.iterator]`, `entries`, `keys`, `values`. Delaying iterator execution prevents performance loss and provides control during traversal. All deletion methods uniformly use the widely adopted `delete` in ES6, while addition methods uniformly use `add`. Compatibility with some specifications in Java.
|
|
43
|
+
- 3. Constructors:The first parameter for all constructors is data, and the second parameter is configuration, maintaining uniformity. The first parameter accepts any iterable type for seamless conversion between data structures.
|
|
44
|
+
- 4. Return types:for example, the `add` method consistently returns a boolean.
|
|
45
|
+
|
|
46
|
+
We would like to provide a more detailed description of this project, but space is limited here. For specific technical details, please refer to the [README.md](https://github.com/zrwusa/data-structure-typed), [SPECIFICATION.md](https://github.com/zrwusa/data-structure-typed/blob/main/CODE_OF_CONDUCT.md), or [API Docs](https://data-structure-typed-docs.vercel.app/).
|
|
47
|
+
|
|
48
|
+
## Community Activity
|
|
49
|
+
|
|
50
|
+
- In terms of community engagement, we have noteworthy metrics including NPM download count , GitHub stars , and contributors .
|
|
51
|
+
|
|
52
|
+
## Sponsor Us
|
|
53
|
+
|
|
54
|
+
- From a software engineering standards perspective, our project has achieved at least 75% completeness. With your sponsorship, we believe we can swiftly elevate the project's completion to 95%, providing valuable assistance to my family and serving as encouragement to our project team. Additionally, we aspire to expedite the goal of becoming an integral part of the `JS/TS` standard library.
|
package/benchmark/report.html
CHANGED
|
@@ -43,43 +43,43 @@
|
|
|
43
43
|
<body>
|
|
44
44
|
<div id="json-to-html"><div class="json-to-html-collapse clearfix 0">
|
|
45
45
|
<div class='collapsible level0' ><span class='json-to-html-label'>avl-tree</span></div>
|
|
46
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 add randomly</td><td>
|
|
46
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 add randomly</td><td>125.60</td><td>7.96</td><td>0.00</td></tr><tr><td>10,000 add & delete randomly</td><td>181.22</td><td>5.52</td><td>0.00</td></tr><tr><td>10,000 addMany</td><td>134.12</td><td>7.46</td><td>0.01</td></tr><tr><td>10,000 get</td><td>55.08</td><td>18.16</td><td>0.01</td></tr></table></div>
|
|
47
47
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
48
48
|
<div class='collapsible level0' ><span class='json-to-html-label'>binary-tree-overall</span></div>
|
|
49
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 RBTree add</td><td>
|
|
49
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 RBTree add</td><td>6.17</td><td>161.95</td><td>0.00</td></tr><tr><td>10,000 RBTree add & delete randomly</td><td>16.07</td><td>62.22</td><td>2.62e-4</td></tr><tr><td>10,000 RBTree get</td><td>19.86</td><td>50.36</td><td>2.44e-4</td></tr><tr><td>10,000 AVLTree add</td><td>134.38</td><td>7.44</td><td>0.02</td></tr><tr><td>10,000 AVLTree add & delete randomly</td><td>207.20</td><td>4.83</td><td>0.06</td></tr><tr><td>10,000 AVLTree get</td><td>0.98</td><td>1015.54</td><td>2.73e-5</td></tr></table></div>
|
|
50
50
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
51
51
|
<div class='collapsible level0' ><span class='json-to-html-label'>rb-tree</span></div>
|
|
52
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>
|
|
52
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>86.65</td><td>11.54</td><td>0.02</td></tr><tr><td>100,000 add & delete randomly</td><td>221.02</td><td>4.52</td><td>0.03</td></tr><tr><td>100,000 getNode</td><td>190.54</td><td>5.25</td><td>0.00</td></tr><tr><td>100,000 add & iterator</td><td>122.10</td><td>8.19</td><td>0.01</td></tr></table></div>
|
|
53
53
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
54
54
|
<div class='collapsible level0' ><span class='json-to-html-label'>directed-graph</span></div>
|
|
55
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000 addVertex</td><td>0.
|
|
55
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000 addVertex</td><td>0.11</td><td>8896.51</td><td>2.63e-5</td></tr><tr><td>1,000 addEdge</td><td>6.53</td><td>153.21</td><td>0.00</td></tr><tr><td>1,000 getVertex</td><td>0.05</td><td>2.08e+4</td><td>1.06e-5</td></tr><tr><td>1,000 getEdge</td><td>27.53</td><td>36.33</td><td>0.01</td></tr><tr><td>tarjan</td><td>224.53</td><td>4.45</td><td>0.01</td></tr><tr><td>topologicalSort</td><td>184.02</td><td>5.43</td><td>0.00</td></tr></table></div>
|
|
56
56
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
57
57
|
<div class='collapsible level0' ><span class='json-to-html-label'>hash-map</span></div>
|
|
58
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 set</td><td>
|
|
58
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 set</td><td>126.27</td><td>7.92</td><td>0.05</td></tr><tr><td>Native Map 1,000,000 set</td><td>229.80</td><td>4.35</td><td>0.03</td></tr><tr><td>Native Set 1,000,000 add</td><td>175.83</td><td>5.69</td><td>0.01</td></tr><tr><td>1,000,000 set & get</td><td>121.34</td><td>8.24</td><td>0.03</td></tr><tr><td>Native Map 1,000,000 set & get</td><td>290.80</td><td>3.44</td><td>0.03</td></tr><tr><td>Native Set 1,000,000 add & has</td><td>180.71</td><td>5.53</td><td>0.01</td></tr><tr><td>1,000,000 ObjKey set & get</td><td>357.68</td><td>2.80</td><td>0.07</td></tr><tr><td>Native Map 1,000,000 ObjKey set & get</td><td>310.57</td><td>3.22</td><td>0.06</td></tr><tr><td>Native Set 1,000,000 ObjKey add & has</td><td>278.42</td><td>3.59</td><td>0.05</td></tr></table></div>
|
|
59
59
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
60
60
|
<div class='collapsible level0' ><span class='json-to-html-label'>heap</span></div>
|
|
61
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add & poll</td><td>
|
|
61
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add & poll</td><td>24.85</td><td>40.24</td><td>0.00</td></tr><tr><td>100,000 add & dfs</td><td>33.14</td><td>30.17</td><td>0.00</td></tr><tr><td>10,000 fib add & pop</td><td>366.11</td><td>2.73</td><td>0.00</td></tr></table></div>
|
|
62
62
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
63
63
|
<div class='collapsible level0' ><span class='json-to-html-label'>doubly-linked-list</span></div>
|
|
64
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>
|
|
64
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>217.98</td><td>4.59</td><td>0.07</td></tr><tr><td>1,000,000 unshift</td><td>223.20</td><td>4.48</td><td>0.08</td></tr><tr><td>1,000,000 unshift & shift</td><td>172.87</td><td>5.78</td><td>0.03</td></tr><tr><td>1,000,000 addBefore</td><td>387.13</td><td>2.58</td><td>0.20</td></tr></table></div>
|
|
65
65
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
66
66
|
<div class='collapsible level0' ><span class='json-to-html-label'>singly-linked-list</span></div>
|
|
67
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push & shift</td><td>
|
|
67
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push & shift</td><td>225.13</td><td>4.44</td><td>0.07</td></tr><tr><td>10,000 push & pop</td><td>234.54</td><td>4.26</td><td>0.02</td></tr><tr><td>10,000 addBefore</td><td>252.62</td><td>3.96</td><td>0.00</td></tr></table></div>
|
|
68
68
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
69
69
|
<div class='collapsible level0' ><span class='json-to-html-label'>priority-queue</span></div>
|
|
70
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add & poll</td><td>
|
|
70
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add & poll</td><td>76.49</td><td>13.07</td><td>0.00</td></tr></table></div>
|
|
71
71
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
72
72
|
<div class='collapsible level0' ><span class='json-to-html-label'>deque</span></div>
|
|
73
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>13.
|
|
73
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>13.20</td><td>75.75</td><td>2.79e-4</td></tr><tr><td>1,000,000 push & pop</td><td>22.21</td><td>45.03</td><td>3.27e-4</td></tr><tr><td>100,000 push & shift</td><td>2.26</td><td>442.24</td><td>1.43e-4</td></tr><tr><td>Native Array 100,000 push & shift</td><td>2329.51</td><td>0.43</td><td>0.10</td></tr><tr><td>100,000 unshift & shift</td><td>2.16</td><td>463.83</td><td>8.20e-5</td></tr><tr><td>Native Array 100,000 unshift & shift</td><td>4590.64</td><td>0.22</td><td>0.33</td></tr></table></div>
|
|
74
74
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
75
75
|
<div class='collapsible level0' ><span class='json-to-html-label'>queue</span></div>
|
|
76
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>
|
|
76
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>49.92</td><td>20.03</td><td>0.02</td></tr><tr><td>100,000 push & shift</td><td>5.07</td><td>197.28</td><td>5.86e-4</td></tr><tr><td>Native Array 100,000 push & shift</td><td>2315.78</td><td>0.43</td><td>0.13</td></tr><tr><td>Native Array 100,000 push & pop</td><td>4.37</td><td>228.72</td><td>1.32e-4</td></tr></table></div>
|
|
77
77
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
78
78
|
<div class='collapsible level0' ><span class='json-to-html-label'>stack</span></div>
|
|
79
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>
|
|
79
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>44.50</td><td>22.47</td><td>0.01</td></tr><tr><td>1,000,000 push & pop</td><td>53.57</td><td>18.67</td><td>0.02</td></tr></table></div>
|
|
80
80
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
81
81
|
<div class='collapsible level0' ><span class='json-to-html-label'>trie</span></div>
|
|
82
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 push</td><td>
|
|
82
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 push</td><td>42.95</td><td>23.28</td><td>6.68e-4</td></tr><tr><td>100,000 getWords</td><td>92.11</td><td>10.86</td><td>0.01</td></tr></table></div>
|
|
83
83
|
</div>
|
|
84
84
|
|
|
85
85
|
</div>
|