data-structure-typed 1.42.5 → 1.42.7
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/CONTRIBUTING.md +66 -5
- package/README.md +218 -126
- package/benchmark/report.html +12 -12
- package/benchmark/report.json +101 -101
- package/dist/cjs/src/data-structures/binary-tree/avl-tree.d.ts +5 -5
- package/dist/cjs/src/data-structures/binary-tree/avl-tree.js +19 -14
- package/dist/cjs/src/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/src/data-structures/binary-tree/binary-tree.d.ts +108 -60
- package/dist/cjs/src/data-structures/binary-tree/binary-tree.js +189 -89
- package/dist/cjs/src/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/src/data-structures/binary-tree/bst.d.ts +30 -8
- package/dist/cjs/src/data-structures/binary-tree/bst.js +77 -28
- package/dist/cjs/src/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/src/data-structures/binary-tree/rb-tree.d.ts +35 -28
- package/dist/cjs/src/data-structures/binary-tree/rb-tree.js +44 -45
- package/dist/cjs/src/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/src/data-structures/binary-tree/tree-multimap.d.ts +7 -12
- package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js +38 -37
- package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/src/interfaces/binary-tree.d.ts +2 -2
- package/dist/cjs/src/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/cjs/src/types/data-structures/binary-tree/binary-tree.js +6 -0
- package/dist/cjs/src/types/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/src/types/data-structures/binary-tree/rb-tree.d.ts +2 -2
- package/dist/mjs/src/data-structures/binary-tree/avl-tree.d.ts +5 -5
- package/dist/mjs/src/data-structures/binary-tree/avl-tree.js +19 -14
- package/dist/mjs/src/data-structures/binary-tree/binary-tree.d.ts +108 -60
- package/dist/mjs/src/data-structures/binary-tree/binary-tree.js +191 -89
- package/dist/mjs/src/data-structures/binary-tree/bst.d.ts +30 -8
- package/dist/mjs/src/data-structures/binary-tree/bst.js +78 -27
- package/dist/mjs/src/data-structures/binary-tree/rb-tree.d.ts +35 -28
- package/dist/mjs/src/data-structures/binary-tree/rb-tree.js +43 -45
- package/dist/mjs/src/data-structures/binary-tree/tree-multimap.d.ts +7 -12
- package/dist/mjs/src/data-structures/binary-tree/tree-multimap.js +38 -37
- package/dist/mjs/src/interfaces/binary-tree.d.ts +2 -2
- package/dist/mjs/src/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/mjs/src/types/data-structures/binary-tree/binary-tree.js +6 -0
- package/dist/mjs/src/types/data-structures/binary-tree/rb-tree.d.ts +2 -2
- package/dist/umd/data-structure-typed.min.js +1 -1
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +5 -5
- package/src/data-structures/binary-tree/avl-tree.ts +24 -18
- package/src/data-structures/binary-tree/binary-tree.ts +248 -142
- package/src/data-structures/binary-tree/bst.ts +88 -38
- package/src/data-structures/binary-tree/rb-tree.ts +52 -58
- package/src/data-structures/binary-tree/tree-multimap.ts +50 -54
- package/src/interfaces/binary-tree.ts +2 -2
- package/src/types/data-structures/binary-tree/binary-tree.ts +7 -1
- package/src/types/data-structures/binary-tree/rb-tree.ts +2 -2
- package/test/performance/reportor.ts +2 -2
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +9 -9
package/README.md
CHANGED
|
@@ -25,11 +25,6 @@ Now you can use this library in Node.js and browser environments in CommonJS(req
|
|
|
25
25
|
[//]: # ()
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
## Built-in classic algorithms
|
|
29
|
-
|
|
30
|
-
DFS(Depth-First Search), DFSIterative, BFS(Breadth-First Search), morris, Bellman-Ford Algorithm, Dijkstra's Algorithm,
|
|
31
|
-
Floyd-Warshall Algorithm, Tarjan's Algorithm.
|
|
32
|
-
|
|
33
28
|
## Installation and Usage
|
|
34
29
|
|
|
35
30
|
### npm
|
|
@@ -54,11 +49,12 @@ import {
|
|
|
54
49
|
|
|
55
50
|
### CDN
|
|
56
51
|
|
|
52
|
+
Copy the line below into the head tag in an HTML document.
|
|
57
53
|
```html
|
|
58
|
-
|
|
59
54
|
<script src='https://cdn.jsdelivr.net/npm/data-structure-typed/dist/umd/data-structure-typed.min.js'></script>
|
|
60
55
|
```
|
|
61
56
|
|
|
57
|
+
Copy the code below into the script tag of your HTML, and you're good to go with your development work.
|
|
62
58
|
```js
|
|
63
59
|
const {Heap} = dataStructureTyped;
|
|
64
60
|
const {
|
|
@@ -76,15 +72,8 @@ const {
|
|
|
76
72
|

|
|
77
73
|

|
|
78
74
|
|
|
79
|
-
## API docs & Examples
|
|
80
|
-
|
|
81
|
-
[API Docs](https://data-structure-typed-docs.vercel.app)
|
|
82
|
-
|
|
83
|
-
[Live Examples](https://vivid-algorithm.vercel.app)
|
|
84
75
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
## Code Snippet
|
|
76
|
+
## Code Snippets
|
|
88
77
|
|
|
89
78
|
### Binary Search Tree (BST) snippet
|
|
90
79
|
|
|
@@ -99,27 +88,40 @@ bst.add(3);
|
|
|
99
88
|
bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
|
|
100
89
|
bst.size === 16; // true
|
|
101
90
|
bst.has(6); // true
|
|
102
|
-
const node6 = bst.
|
|
91
|
+
const node6 = bst.getNode(6); // BSTNode
|
|
103
92
|
bst.getHeight(6) === 2; // true
|
|
104
93
|
bst.getHeight() === 5; // true
|
|
105
94
|
bst.getDepth(6) === 3; // true
|
|
106
95
|
|
|
107
|
-
bst.getLeftMost()?.
|
|
96
|
+
bst.getLeftMost()?.key === 1; // true
|
|
108
97
|
|
|
109
98
|
bst.delete(6);
|
|
110
|
-
bst.get(6); //
|
|
99
|
+
bst.get(6); // undefined
|
|
111
100
|
bst.isAVLBalanced(); // true
|
|
112
101
|
bst.bfs()[0] === 11; // true
|
|
113
102
|
|
|
114
|
-
const objBST = new BST<
|
|
115
|
-
|
|
116
|
-
objBST.add(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
103
|
+
const objBST = new BST<{height: number, age: number}>();
|
|
104
|
+
|
|
105
|
+
objBST.add(11, { "name": "Pablo", "age": 15 });
|
|
106
|
+
objBST.add(3, { "name": "Kirk", "age": 1 });
|
|
107
|
+
|
|
108
|
+
objBST.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5], [
|
|
109
|
+
{ "name": "Alice", "age": 15 },
|
|
110
|
+
{ "name": "Bob", "age": 1 },
|
|
111
|
+
{ "name": "Charlie", "age": 8 },
|
|
112
|
+
{ "name": "David", "age": 13 },
|
|
113
|
+
{ "name": "Emma", "age": 16 },
|
|
114
|
+
{ "name": "Frank", "age": 2 },
|
|
115
|
+
{ "name": "Grace", "age": 6 },
|
|
116
|
+
{ "name": "Hannah", "age": 9 },
|
|
117
|
+
{ "name": "Isaac", "age": 12 },
|
|
118
|
+
{ "name": "Jack", "age": 14 },
|
|
119
|
+
{ "name": "Katie", "age": 4 },
|
|
120
|
+
{ "name": "Liam", "age": 7 },
|
|
121
|
+
{ "name": "Mia", "age": 10 },
|
|
122
|
+
{ "name": "Noah", "age": 5 }
|
|
123
|
+
]
|
|
124
|
+
);
|
|
123
125
|
|
|
124
126
|
objBST.delete(11);
|
|
125
127
|
```
|
|
@@ -133,39 +135,21 @@ const bst = new BST();
|
|
|
133
135
|
bst.add(11);
|
|
134
136
|
bst.add(3);
|
|
135
137
|
bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
|
|
136
|
-
bst.size === 16;
|
|
137
|
-
bst.has(6);
|
|
138
|
-
const node6 = bst.
|
|
139
|
-
bst.getHeight(6) === 2;
|
|
140
|
-
bst.getHeight() === 5;
|
|
141
|
-
bst.getDepth(6) === 3;
|
|
138
|
+
bst.size === 16; // true
|
|
139
|
+
bst.has(6); // true
|
|
140
|
+
const node6 = bst.getNode(6);
|
|
141
|
+
bst.getHeight(6) === 2; // true
|
|
142
|
+
bst.getHeight() === 5; // true
|
|
143
|
+
bst.getDepth(6) === 3; // true
|
|
142
144
|
const leftMost = bst.getLeftMost();
|
|
143
|
-
leftMost?.
|
|
144
|
-
|
|
145
|
+
leftMost?.key === 1; // true
|
|
146
|
+
|
|
145
147
|
bst.delete(6);
|
|
146
|
-
bst.get(6);
|
|
147
|
-
bst.isAVLBalanced();
|
|
148
|
+
bst.get(6); // undefined
|
|
149
|
+
bst.isAVLBalanced(); // true or false
|
|
148
150
|
const bfsIDs = bst.bfs();
|
|
149
|
-
bfsIDs[0] === 11;
|
|
150
|
-
expect(bfsIDs[0]).toBe(11);
|
|
151
|
+
bfsIDs[0] === 11; // true
|
|
151
152
|
|
|
152
|
-
const objBST = new BST();
|
|
153
|
-
objBST.add(11, {id: 11, keyA: 11});
|
|
154
|
-
objBST.add(3, {id: 3, keyA: 3});
|
|
155
|
-
|
|
156
|
-
objBST.addMany([{id: 15, keyA: 15}, {id: 1, keyA: 1}, {id: 8, keyA: 8},
|
|
157
|
-
{id: 13, keyA: 13}, {id: 16, keyA: 16}, {id: 2, keyA: 2},
|
|
158
|
-
{id: 6, keyA: 6}, {id: 9, keyA: 9}, {id: 12, keyA: 12},
|
|
159
|
-
{id: 14, keyA: 14}, {id: 4, keyA: 4}, {id: 7, keyA: 7},
|
|
160
|
-
{id: 10, keyA: 10}, {id: 5, keyA: 5}]);
|
|
161
|
-
|
|
162
|
-
objBST.delete(11);
|
|
163
|
-
|
|
164
|
-
const avlTree = new AVLTree();
|
|
165
|
-
avlTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5])
|
|
166
|
-
avlTree.isAVLBalanced(); // true
|
|
167
|
-
avlTree.delete(10);
|
|
168
|
-
avlTree.isAVLBalanced(); // true
|
|
169
153
|
```
|
|
170
154
|
|
|
171
155
|
### AVLTree snippet
|
|
@@ -222,7 +206,7 @@ graph.addVertex('C');
|
|
|
222
206
|
graph.addEdge('A', 'B');
|
|
223
207
|
graph.addEdge('B', 'C');
|
|
224
208
|
|
|
225
|
-
const
|
|
209
|
+
const topologicalOrderKeys = graph.topologicalSort(); // ['A', 'B', 'C']
|
|
226
210
|
```
|
|
227
211
|
|
|
228
212
|
### Undirected Graph snippet
|
|
@@ -242,9 +226,118 @@ graph.addEdge('A', 'B');
|
|
|
242
226
|
graph.addEdge('B', 'D');
|
|
243
227
|
|
|
244
228
|
const dijkstraResult = graph.dijkstra('A');
|
|
245
|
-
Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.
|
|
229
|
+
Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.key) // ['A', 'B', 'D']
|
|
246
230
|
```
|
|
247
231
|
|
|
232
|
+
## Built-in classic algorithms
|
|
233
|
+
|
|
234
|
+
<table>
|
|
235
|
+
<thead>
|
|
236
|
+
<tr>
|
|
237
|
+
<th>Algorithm</th>
|
|
238
|
+
<th>Function Description</th>
|
|
239
|
+
<th>Iteration Type</th>
|
|
240
|
+
</tr>
|
|
241
|
+
</thead>
|
|
242
|
+
<tbody>
|
|
243
|
+
<tr>
|
|
244
|
+
<td>Binary Tree DFS</td>
|
|
245
|
+
<td>Traverse a binary tree in a depth-first manner, starting from the root node, first visiting the left subtree,
|
|
246
|
+
and then the right subtree, using recursion.
|
|
247
|
+
</td>
|
|
248
|
+
<td>Recursion + Iteration</td>
|
|
249
|
+
</tr>
|
|
250
|
+
<tr>
|
|
251
|
+
<td>Binary Tree BFS</td>
|
|
252
|
+
<td>Traverse a binary tree in a breadth-first manner, starting from the root node, visiting nodes level by level
|
|
253
|
+
from left to right.
|
|
254
|
+
</td>
|
|
255
|
+
<td>Iteration</td>
|
|
256
|
+
</tr>
|
|
257
|
+
<tr>
|
|
258
|
+
<td>Graph DFS</td>
|
|
259
|
+
<td>Traverse a graph in a depth-first manner, starting from a given node, exploring along one path as deeply as
|
|
260
|
+
possible, and backtracking to explore other paths. Used for finding connected components, paths, etc.
|
|
261
|
+
</td>
|
|
262
|
+
<td>Recursion + Iteration</td>
|
|
263
|
+
</tr>
|
|
264
|
+
<tr>
|
|
265
|
+
<td>Binary Tree Morris</td>
|
|
266
|
+
<td>Morris traversal is an in-order traversal algorithm for binary trees with O(1) space complexity. It allows tree
|
|
267
|
+
traversal without additional stack or recursion.
|
|
268
|
+
</td>
|
|
269
|
+
<td>Iteration</td>
|
|
270
|
+
</tr>
|
|
271
|
+
<tr>
|
|
272
|
+
<td>Graph BFS</td>
|
|
273
|
+
<td>Traverse a graph in a breadth-first manner, starting from a given node, first visiting nodes directly connected
|
|
274
|
+
to the starting node, and then expanding level by level. Used for finding shortest paths, etc.
|
|
275
|
+
</td>
|
|
276
|
+
<td>Recursion + Iteration</td>
|
|
277
|
+
</tr>
|
|
278
|
+
<tr>
|
|
279
|
+
<td>Graph Tarjan's Algorithm</td>
|
|
280
|
+
<td>Find strongly connected components in a graph, typically implemented using depth-first search.</td>
|
|
281
|
+
<td>Recursion</td>
|
|
282
|
+
</tr>
|
|
283
|
+
<tr>
|
|
284
|
+
<td>Graph Bellman-Ford Algorithm</td>
|
|
285
|
+
<td>Finding the shortest paths from a single source, can handle negative weight edges</td>
|
|
286
|
+
<td>Iteration</td>
|
|
287
|
+
</tr>
|
|
288
|
+
<tr>
|
|
289
|
+
<td>Graph Dijkstra's Algorithm</td>
|
|
290
|
+
<td>Finding the shortest paths from a single source, cannot handle negative weight edges</td>
|
|
291
|
+
<td>Iteration</td>
|
|
292
|
+
</tr>
|
|
293
|
+
<tr>
|
|
294
|
+
<td>Graph Floyd-Warshall Algorithm</td>
|
|
295
|
+
<td>Finding the shortest paths between all pairs of nodes</td>
|
|
296
|
+
<td>Iteration</td>
|
|
297
|
+
</tr>
|
|
298
|
+
<tr>
|
|
299
|
+
<td>Graph getCycles</td>
|
|
300
|
+
<td>Find all cycles in a graph or detect the presence of cycles.</td>
|
|
301
|
+
<td>Recursion</td>
|
|
302
|
+
</tr>
|
|
303
|
+
<tr>
|
|
304
|
+
<td>Graph getCutVertexes</td>
|
|
305
|
+
<td>Find cut vertices in a graph, which are nodes that, when removed, increase the number of connected components in
|
|
306
|
+
the graph.
|
|
307
|
+
</td>
|
|
308
|
+
<td>Recursion</td>
|
|
309
|
+
</tr>
|
|
310
|
+
<tr>
|
|
311
|
+
<td>Graph getSCCs</td>
|
|
312
|
+
<td>Find strongly connected components in a graph, which are subgraphs where any two nodes can reach each other.
|
|
313
|
+
</td>
|
|
314
|
+
<td>Recursion</td>
|
|
315
|
+
</tr>
|
|
316
|
+
<tr>
|
|
317
|
+
<td>Graph getBridges</td>
|
|
318
|
+
<td>Find bridges in a graph, which are edges that, when removed, increase the number of connected components in the
|
|
319
|
+
graph.
|
|
320
|
+
</td>
|
|
321
|
+
<td>Recursion</td>
|
|
322
|
+
</tr>
|
|
323
|
+
<tr>
|
|
324
|
+
<td>Graph topologicalSort</td>
|
|
325
|
+
<td>Perform topological sorting on a directed acyclic graph (DAG) to find a linear order of nodes such that all
|
|
326
|
+
directed edges go from earlier nodes to later nodes.
|
|
327
|
+
</td>
|
|
328
|
+
<td>Recursion</td>
|
|
329
|
+
</tr>
|
|
330
|
+
</tbody>
|
|
331
|
+
</table>
|
|
332
|
+
|
|
333
|
+
## API docs & Examples
|
|
334
|
+
|
|
335
|
+
[API Docs](https://data-structure-typed-docs.vercel.app)
|
|
336
|
+
|
|
337
|
+
[Live Examples](https://vivid-algorithm.vercel.app)
|
|
338
|
+
|
|
339
|
+
<a href="https://github.com/zrwusa/vivid-algorithm" target="_blank">Examples Repository</a>
|
|
340
|
+
|
|
248
341
|
## Data Structures
|
|
249
342
|
|
|
250
343
|
<table>
|
|
@@ -283,7 +376,7 @@ Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id) // ['A', 'B', 'D
|
|
|
283
376
|
<td>Red Black Tree</td>
|
|
284
377
|
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
285
378
|
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
286
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/RedBlackTree.html"><span>
|
|
379
|
+
<td><a href="https://data-structure-typed-docs.vercel.app/classes/RedBlackTree.html"><span>RedBlackTree</span></a></td>
|
|
287
380
|
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
288
381
|
</tr>
|
|
289
382
|
<tr>
|
|
@@ -444,12 +537,6 @@ Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id) // ['A', 'B', 'D
|
|
|
444
537
|
</tr>
|
|
445
538
|
</thead>
|
|
446
539
|
<tbody>
|
|
447
|
-
<tr>
|
|
448
|
-
<td>Array<E></td>
|
|
449
|
-
<td>vector<T></td>
|
|
450
|
-
<td>ArrayList<E></td>
|
|
451
|
-
<td>list</td>
|
|
452
|
-
</tr>
|
|
453
540
|
<tr>
|
|
454
541
|
<td>DoublyLinkedList<E></td>
|
|
455
542
|
<td>list<T></td>
|
|
@@ -463,30 +550,23 @@ Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id) // ['A', 'B', 'D
|
|
|
463
550
|
<td>-</td>
|
|
464
551
|
</tr>
|
|
465
552
|
<tr>
|
|
466
|
-
<td>
|
|
467
|
-
<td>
|
|
468
|
-
<td>
|
|
469
|
-
<td>
|
|
470
|
-
</tr>
|
|
471
|
-
<tr>
|
|
472
|
-
<td>Map<K, V></td>
|
|
473
|
-
<td>map<K, V></td>
|
|
474
|
-
<td>HashMap<K, V></td>
|
|
475
|
-
<td>dict</td>
|
|
476
|
-
</tr>
|
|
477
|
-
<tr>
|
|
478
|
-
<td>Map<K, V></td>
|
|
479
|
-
<td>-</td>
|
|
480
|
-
<td>-</td>
|
|
481
|
-
<td>OrderedDict</td>
|
|
553
|
+
<td>Array<E></td>
|
|
554
|
+
<td>vector<T></td>
|
|
555
|
+
<td>ArrayList<E></td>
|
|
556
|
+
<td>list</td>
|
|
482
557
|
</tr>
|
|
483
|
-
|
|
484
558
|
<tr>
|
|
485
559
|
<td>Queue<E></td>
|
|
486
560
|
<td>queue<T></td>
|
|
487
561
|
<td>Queue<E></td>
|
|
488
562
|
<td>-</td>
|
|
489
563
|
</tr>
|
|
564
|
+
<tr>
|
|
565
|
+
<td>Deque<E></td>
|
|
566
|
+
<td>deque<T></td>
|
|
567
|
+
<td>-</td>
|
|
568
|
+
<td>-</td>
|
|
569
|
+
</tr>
|
|
490
570
|
<tr>
|
|
491
571
|
<td>PriorityQueue<E></td>
|
|
492
572
|
<td>priority_queue<T></td>
|
|
@@ -494,7 +574,7 @@ Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id) // ['A', 'B', 'D
|
|
|
494
574
|
<td>-</td>
|
|
495
575
|
</tr>
|
|
496
576
|
<tr>
|
|
497
|
-
<td>Heap<
|
|
577
|
+
<td>Heap<E></td>
|
|
498
578
|
<td>priority_queue<T></td>
|
|
499
579
|
<td>PriorityQueue<E></td>
|
|
500
580
|
<td>heapq</td>
|
|
@@ -506,15 +586,21 @@ Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id) // ['A', 'B', 'D
|
|
|
506
586
|
<td>-</td>
|
|
507
587
|
</tr>
|
|
508
588
|
<tr>
|
|
509
|
-
<td>
|
|
510
|
-
<td>
|
|
511
|
-
<td
|
|
512
|
-
<td
|
|
589
|
+
<td>Set<E></td>
|
|
590
|
+
<td>set<T></td>
|
|
591
|
+
<td>HashSet<E></td>
|
|
592
|
+
<td>set</td>
|
|
593
|
+
</tr>
|
|
594
|
+
<tr>
|
|
595
|
+
<td>Map<K, V></td>
|
|
596
|
+
<td>map<K, V></td>
|
|
597
|
+
<td>HashMap<K, V></td>
|
|
598
|
+
<td>dict</td>
|
|
513
599
|
</tr>
|
|
514
600
|
<tr>
|
|
515
|
-
<td>Trie</td>
|
|
516
|
-
<td>-</td>
|
|
517
601
|
<td>-</td>
|
|
602
|
+
<td>unordered_set<T></td>
|
|
603
|
+
<td>HashSet<E></td>
|
|
518
604
|
<td>-</td>
|
|
519
605
|
</tr>
|
|
520
606
|
<tr>
|
|
@@ -524,93 +610,99 @@ Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id) // ['A', 'B', 'D
|
|
|
524
610
|
<td>defaultdict</td>
|
|
525
611
|
</tr>
|
|
526
612
|
<tr>
|
|
527
|
-
<td
|
|
528
|
-
<td>multiset<T></td>
|
|
613
|
+
<td>Map<K, V></td>
|
|
529
614
|
<td>-</td>
|
|
530
615
|
<td>-</td>
|
|
616
|
+
<td>OrderedDict</td>
|
|
531
617
|
</tr>
|
|
532
618
|
<tr>
|
|
619
|
+
<td>BinaryTree<K, V></td>
|
|
533
620
|
<td>-</td>
|
|
534
|
-
<td>multimap<K, V></td>
|
|
535
621
|
<td>-</td>
|
|
536
622
|
<td>-</td>
|
|
537
623
|
</tr>
|
|
538
624
|
<tr>
|
|
539
|
-
<td>
|
|
625
|
+
<td>BST<K, V></td>
|
|
540
626
|
<td>-</td>
|
|
541
627
|
<td>-</td>
|
|
542
628
|
<td>-</td>
|
|
543
629
|
</tr>
|
|
544
630
|
<tr>
|
|
545
|
-
<td>
|
|
546
|
-
<td
|
|
631
|
+
<td>TreeMultimap<K, V></td>
|
|
632
|
+
<td>multimap<K, V></td>
|
|
547
633
|
<td>-</td>
|
|
548
634
|
<td>-</td>
|
|
549
635
|
</tr>
|
|
550
636
|
<tr>
|
|
551
|
-
<td>
|
|
552
|
-
<td>-</td>
|
|
637
|
+
<td>AVLTree<E></td>
|
|
553
638
|
<td>-</td>
|
|
639
|
+
<td>TreeSet<E></td>
|
|
554
640
|
<td>-</td>
|
|
555
641
|
</tr>
|
|
556
642
|
<tr>
|
|
557
|
-
<td>
|
|
643
|
+
<td>AVLTree<K, V></td>
|
|
558
644
|
<td>-</td>
|
|
645
|
+
<td>TreeMap<K, V></td>
|
|
559
646
|
<td>-</td>
|
|
647
|
+
</tr>
|
|
648
|
+
<tr>
|
|
649
|
+
<td>AVLTree<E></td>
|
|
650
|
+
<td>set</td>
|
|
651
|
+
<td>TreeSet<E></td>
|
|
560
652
|
<td>-</td>
|
|
561
653
|
</tr>
|
|
562
654
|
<tr>
|
|
655
|
+
<td>Trie</td>
|
|
656
|
+
<td>-</td>
|
|
563
657
|
<td>-</td>
|
|
564
|
-
<td>unordered_multiset</td>
|
|
565
658
|
<td>-</td>
|
|
566
|
-
<td>Counter</td>
|
|
567
659
|
</tr>
|
|
568
660
|
<tr>
|
|
569
661
|
<td>-</td>
|
|
662
|
+
<td>multiset<T></td>
|
|
570
663
|
<td>-</td>
|
|
571
|
-
<td>LinkedHashSet<E></td>
|
|
572
664
|
<td>-</td>
|
|
573
665
|
</tr>
|
|
574
666
|
<tr>
|
|
667
|
+
<td>DirectedGraph<V, E></td>
|
|
575
668
|
<td>-</td>
|
|
576
669
|
<td>-</td>
|
|
577
|
-
<td>LinkedHashMap<K, V></td>
|
|
578
670
|
<td>-</td>
|
|
579
671
|
</tr>
|
|
580
672
|
<tr>
|
|
581
|
-
<td>
|
|
673
|
+
<td>UndirectedGraph<V, E></td>
|
|
674
|
+
<td>-</td>
|
|
582
675
|
<td>-</td>
|
|
583
|
-
<td>TreeSet<E></td>
|
|
584
676
|
<td>-</td>
|
|
585
677
|
</tr>
|
|
586
678
|
<tr>
|
|
587
|
-
<td>AVLTree<K, V></td>
|
|
588
679
|
<td>-</td>
|
|
589
|
-
<td>
|
|
680
|
+
<td>unordered_multiset</td>
|
|
590
681
|
<td>-</td>
|
|
682
|
+
<td>Counter</td>
|
|
591
683
|
</tr>
|
|
592
684
|
<tr>
|
|
593
|
-
<td
|
|
594
|
-
<td
|
|
595
|
-
<td>
|
|
685
|
+
<td>-</td>
|
|
686
|
+
<td>-</td>
|
|
687
|
+
<td>LinkedHashSet<E></td>
|
|
596
688
|
<td>-</td>
|
|
597
689
|
</tr>
|
|
598
690
|
<tr>
|
|
599
691
|
<td>-</td>
|
|
600
|
-
<td>unordered_multimap<K, V></td>
|
|
601
692
|
<td>-</td>
|
|
693
|
+
<td>LinkedHashMap<K, V></td>
|
|
602
694
|
<td>-</td>
|
|
603
695
|
</tr>
|
|
604
696
|
<tr>
|
|
605
697
|
<td>-</td>
|
|
606
|
-
<td>
|
|
698
|
+
<td>unordered_multimap<K, V></td>
|
|
607
699
|
<td>-</td>
|
|
608
700
|
<td>-</td>
|
|
609
701
|
</tr>
|
|
610
702
|
<tr>
|
|
611
703
|
<td>-</td>
|
|
612
|
-
<td>
|
|
613
|
-
<td
|
|
704
|
+
<td>bitset<N></td>
|
|
705
|
+
<td>-</td>
|
|
614
706
|
<td>-</td>
|
|
615
707
|
</tr>
|
|
616
708
|
</tbody>
|
|
@@ -633,43 +725,43 @@ optimal approach to data structure design.
|
|
|
633
725
|
|
|
634
726
|
## Benchmark
|
|
635
727
|
|
|
636
|
-
[//]: # (Start of Replace Section)
|
|
728
|
+
[//]: # (No deletion!!! Start of Replace Section)
|
|
637
729
|
<div class="json-to-html-collapse clearfix 0">
|
|
638
730
|
<div class='collapsible level0' ><span class='json-to-html-label'>avl-tree</span></div>
|
|
639
|
-
<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>
|
|
731
|
+
<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>45.48</td><td>21.99</td><td>0.04</td></tr><tr><td>10,000 add & delete randomly</td><td>132.35</td><td>7.56</td><td>0.10</td></tr><tr><td>10,000 addMany</td><td>79.22</td><td>12.62</td><td>0.07</td></tr><tr><td>10,000 get</td><td>93.13</td><td>10.74</td><td>0.06</td></tr></table></div>
|
|
640
732
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
641
733
|
<div class='collapsible level0' ><span class='json-to-html-label'>binary-tree</span></div>
|
|
642
|
-
<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 add randomly</td><td>
|
|
734
|
+
<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 add randomly</td><td>23.89</td><td>41.85</td><td>0.01</td></tr><tr><td>1,000 add & delete randomly</td><td>22.84</td><td>43.78</td><td>0.01</td></tr><tr><td>1,000 addMany</td><td>10.61</td><td>94.22</td><td>4.91e-4</td></tr><tr><td>1,000 get</td><td>18.56</td><td>53.87</td><td>8.86e-4</td></tr><tr><td>1,000 dfs</td><td>158.90</td><td>6.29</td><td>0.00</td></tr><tr><td>1,000 bfs</td><td>58.59</td><td>17.07</td><td>0.00</td></tr><tr><td>1,000 morris</td><td>269.91</td><td>3.70</td><td>0.01</td></tr></table></div>
|
|
643
735
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
644
736
|
<div class='collapsible level0' ><span class='json-to-html-label'>bst</span></div>
|
|
645
|
-
<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>
|
|
737
|
+
<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>31.66</td><td>31.59</td><td>8.90e-4</td></tr><tr><td>10,000 add & delete randomly</td><td>73.97</td><td>13.52</td><td>0.00</td></tr><tr><td>10,000 addMany</td><td>31.66</td><td>31.58</td><td>0.00</td></tr><tr><td>10,000 get</td><td>29.75</td><td>33.61</td><td>5.49e-4</td></tr></table></div>
|
|
646
738
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
647
739
|
<div class='collapsible level0' ><span class='json-to-html-label'>rb-tree</span></div>
|
|
648
|
-
<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 randomly</td><td>87.
|
|
740
|
+
<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 randomly</td><td>87.24</td><td>11.46</td><td>0.00</td></tr><tr><td>100,000 add & delete randomly</td><td>218.78</td><td>4.57</td><td>0.01</td></tr><tr><td>100,000 getNode</td><td>91.39</td><td>10.94</td><td>0.00</td></tr></table></div>
|
|
649
741
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
650
742
|
<div class='collapsible level0' ><span class='json-to-html-label'>directed-graph</span></div>
|
|
651
|
-
<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.10</td><td>
|
|
743
|
+
<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.10</td><td>9631.84</td><td>5.21e-6</td></tr><tr><td>1,000 addEdge</td><td>6.25</td><td>160.06</td><td>3.97e-4</td></tr><tr><td>1,000 getVertex</td><td>0.05</td><td>2.13e+4</td><td>1.05e-6</td></tr><tr><td>1,000 getEdge</td><td>23.83</td><td>41.97</td><td>0.00</td></tr><tr><td>tarjan</td><td>217.69</td><td>4.59</td><td>0.01</td></tr><tr><td>tarjan all</td><td>226.43</td><td>4.42</td><td>0.01</td></tr><tr><td>topologicalSort</td><td>180.71</td><td>5.53</td><td>0.01</td></tr></table></div>
|
|
652
744
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
653
745
|
<div class='collapsible level0' ><span class='json-to-html-label'>heap</span></div>
|
|
654
|
-
<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 & pop</td><td>4.
|
|
746
|
+
<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 & pop</td><td>4.69</td><td>213.13</td><td>1.63e-4</td></tr><tr><td>10,000 fib add & pop</td><td>367.49</td><td>2.72</td><td>0.01</td></tr></table></div>
|
|
655
747
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
656
748
|
<div class='collapsible level0' ><span class='json-to-html-label'>doubly-linked-list</span></div>
|
|
657
|
-
<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 unshift</td><td>
|
|
749
|
+
<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 unshift</td><td>221.10</td><td>4.52</td><td>0.06</td></tr><tr><td>1,000,000 unshift & shift</td><td>179.99</td><td>5.56</td><td>0.03</td></tr><tr><td>1,000,000 insertBefore</td><td>331.29</td><td>3.02</td><td>0.06</td></tr></table></div>
|
|
658
750
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
659
751
|
<div class='collapsible level0' ><span class='json-to-html-label'>singly-linked-list</span></div>
|
|
660
|
-
<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 push & pop</td><td>
|
|
752
|
+
<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 push & pop</td><td>216.59</td><td>4.62</td><td>0.01</td></tr><tr><td>10,000 insertBefore</td><td>255.08</td><td>3.92</td><td>0.01</td></tr></table></div>
|
|
661
753
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
662
754
|
<div class='collapsible level0' ><span class='json-to-html-label'>max-priority-queue</span></div>
|
|
663
|
-
<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 refill & poll</td><td>
|
|
755
|
+
<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 refill & poll</td><td>12.00</td><td>83.34</td><td>6.62e-4</td></tr></table></div>
|
|
664
756
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
665
757
|
<div class='collapsible level0' ><span class='json-to-html-label'>deque</span></div>
|
|
666
|
-
<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>
|
|
758
|
+
<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>222.01</td><td>4.50</td><td>0.05</td></tr><tr><td>1,000,000 shift</td><td>25.35</td><td>39.45</td><td>0.00</td></tr></table></div>
|
|
667
759
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
668
760
|
<div class='collapsible level0' ><span class='json-to-html-label'>queue</span></div>
|
|
669
|
-
<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>45.
|
|
761
|
+
<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>45.31</td><td>22.07</td><td>0.01</td></tr><tr><td>1,000,000 push & shift</td><td>83.92</td><td>11.92</td><td>0.01</td></tr></table></div>
|
|
670
762
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
671
763
|
<div class='collapsible level0' ><span class='json-to-html-label'>trie</span></div>
|
|
672
|
-
<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>59.
|
|
764
|
+
<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>59.08</td><td>16.92</td><td>0.01</td></tr><tr><td>100,000 getWords</td><td>95.74</td><td>10.44</td><td>0.01</td></tr></table></div>
|
|
673
765
|
</div>
|
|
674
766
|
|
|
675
|
-
[//]: # (End of Replace Section)
|
|
767
|
+
[//]: # (No deletion!!! End of Replace Section)
|