directed-graph-typed 1.51.3 → 1.51.4
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/README.md +0 -342
- package/dist/data-structures/binary-tree/binary-tree.js +2 -2
- package/dist/data-structures/binary-tree/bst.js +1 -1
- package/dist/data-structures/index.d.ts +1 -1
- package/dist/data-structures/index.js +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/number.d.ts +1 -0
- package/dist/utils/number.js +11 -0
- package/package.json +2 -2
- package/src/data-structures/binary-tree/binary-tree.ts +2 -2
- package/src/data-structures/binary-tree/bst.ts +1 -1
- package/src/data-structures/index.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/number.ts +9 -0
package/README.md
CHANGED
|
@@ -70,131 +70,11 @@ yarn add directed-graph-typed
|
|
|
70
70
|
</thead>
|
|
71
71
|
<tbody>
|
|
72
72
|
<tr>
|
|
73
|
-
<td>Binary Tree</td>
|
|
74
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
75
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
76
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html"><span>Binary Tree</span></a></td>
|
|
77
|
-
</tr>
|
|
78
|
-
<tr>
|
|
79
|
-
<td>Binary Search Tree (BST)</td>
|
|
80
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
81
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
82
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BST.html"><span>BST</span></a></td>
|
|
83
|
-
</tr>
|
|
84
|
-
<tr>
|
|
85
|
-
<td>AVL Tree</td>
|
|
86
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
87
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
88
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTree.html"><span>AVLTree</span></a></td>
|
|
89
|
-
</tr>
|
|
90
|
-
<tr>
|
|
91
|
-
<td>Red Black Tree</td>
|
|
92
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
93
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
94
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/RedBlackTree.html"><span>RedBlackTree</span></a></td>
|
|
95
|
-
</tr>
|
|
96
|
-
<tr>
|
|
97
|
-
<td>Tree Multiset</td>
|
|
98
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
99
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
100
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/TreeMultimap.html"><span>TreeMultimap</span></a></td>
|
|
101
|
-
</tr>
|
|
102
|
-
<tr>
|
|
103
|
-
<td>Segment Tree</td>
|
|
104
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
105
|
-
<td></td>
|
|
106
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTree.html"><span>SegmentTree</span></a></td>
|
|
107
|
-
</tr>
|
|
108
|
-
<tr>
|
|
109
|
-
<td>Binary Indexed Tree</td>
|
|
110
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
111
|
-
<td></td>
|
|
112
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryIndexedTree.html"><span>BinaryIndexedTree</span></a></td>
|
|
113
|
-
</tr>
|
|
114
|
-
<tr>
|
|
115
|
-
<td>Heap</td>
|
|
116
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
117
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
118
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Heap.html"><span>Heap</span></a></td>
|
|
119
|
-
</tr>
|
|
120
|
-
<tr>
|
|
121
|
-
<td>Priority Queue</td>
|
|
122
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
123
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
124
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/PriorityQueue.html"><span>PriorityQueue</span></a></td>
|
|
125
|
-
</tr>
|
|
126
|
-
<tr>
|
|
127
|
-
<td>Max Priority Queue</td>
|
|
128
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
129
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
130
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/MaxPriorityQueue.html"><span>MaxPriorityQueue</span></a></td>
|
|
131
|
-
</tr>
|
|
132
|
-
<tr>
|
|
133
|
-
<td>Min Priority Queue</td>
|
|
134
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
135
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
136
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/MinPriorityQueue.html"><span>MinPriorityQueue</span></a></td>
|
|
137
|
-
</tr>
|
|
138
|
-
<tr>
|
|
139
|
-
<td>Trie</td>
|
|
140
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
141
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
142
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Trie.html"><span>Trie</span></a></td>
|
|
143
|
-
</tr>
|
|
144
|
-
<tr>
|
|
145
|
-
<td>Graph</td>
|
|
146
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
147
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
148
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractGraph.html"><span>AbstractGraph</span></a></td>
|
|
149
|
-
</tr>
|
|
150
|
-
<tr>
|
|
151
73
|
<td>Directed Graph</td>
|
|
152
74
|
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
153
75
|
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
154
76
|
<td><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedGraph.html"><span>DirectedGraph</span></a></td>
|
|
155
77
|
</tr>
|
|
156
|
-
<tr>
|
|
157
|
-
<td>Undirected Graph</td>
|
|
158
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
159
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
160
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedGraph.html"><span>UndirectedGraph</span></a></td>
|
|
161
|
-
</tr>
|
|
162
|
-
<tr>
|
|
163
|
-
<td>Queue</td>
|
|
164
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
165
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
166
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Queue.html"><span>Queue</span></a></td>
|
|
167
|
-
</tr>
|
|
168
|
-
<tr>
|
|
169
|
-
<td>Deque</td>
|
|
170
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
171
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
172
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Deque.html"><span>Deque</span></a></td>
|
|
173
|
-
</tr>
|
|
174
|
-
<tr>
|
|
175
|
-
<td>Linked List</td>
|
|
176
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
177
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
178
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>SinglyLinkedList</span></a></td>
|
|
179
|
-
</tr>
|
|
180
|
-
<tr>
|
|
181
|
-
<td>Singly Linked List</td>
|
|
182
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
183
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
184
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>SinglyLinkedList</span></a></td>
|
|
185
|
-
</tr>
|
|
186
|
-
<tr>
|
|
187
|
-
<td>Doubly Linked List</td>
|
|
188
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
189
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
190
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedList.html"><span>DoublyLinkedList</span></a></td>
|
|
191
|
-
</tr>
|
|
192
|
-
<tr>
|
|
193
|
-
<td>Stack</td>
|
|
194
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
195
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
196
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html"><span>Stack</span></a></td>
|
|
197
|
-
</tr>
|
|
198
78
|
</tbody>
|
|
199
79
|
</table>
|
|
200
80
|
|
|
@@ -210,168 +90,12 @@ yarn add directed-graph-typed
|
|
|
210
90
|
</tr>
|
|
211
91
|
</thead>
|
|
212
92
|
<tbody>
|
|
213
|
-
<tr>
|
|
214
|
-
<td>Heap<E></td>
|
|
215
|
-
<td>priority_queue<T></td>
|
|
216
|
-
<td>PriorityQueue<E></td>
|
|
217
|
-
<td>heapq</td>
|
|
218
|
-
</tr>
|
|
219
|
-
<tr>
|
|
220
|
-
<td>Deque<E></td>
|
|
221
|
-
<td>deque<T></td>
|
|
222
|
-
<td>ArrayDeque<E></td>
|
|
223
|
-
<td>deque</td>
|
|
224
|
-
</tr>
|
|
225
|
-
<tr>
|
|
226
|
-
<td>Queue<E></td>
|
|
227
|
-
<td>queue<T></td>
|
|
228
|
-
<td>Queue<E></td>
|
|
229
|
-
<td>-</td>
|
|
230
|
-
</tr>
|
|
231
|
-
<tr>
|
|
232
|
-
<td>HashMap<K, V></td>
|
|
233
|
-
<td>unordered_map<K, V></td>
|
|
234
|
-
<td>HashMap<K, V></td>
|
|
235
|
-
<td>defaultdict</td>
|
|
236
|
-
</tr>
|
|
237
|
-
<tr>
|
|
238
|
-
<td>DoublyLinkedList<E></td>
|
|
239
|
-
<td>list<T></td>
|
|
240
|
-
<td>LinkedList<E></td>
|
|
241
|
-
<td>-</td>
|
|
242
|
-
</tr>
|
|
243
|
-
<tr>
|
|
244
|
-
<td>SinglyLinkedList<E></td>
|
|
245
|
-
<td>-</td>
|
|
246
|
-
<td>-</td>
|
|
247
|
-
<td>-</td>
|
|
248
|
-
</tr>
|
|
249
|
-
<tr>
|
|
250
|
-
<td>BinaryTree<K, V></td>
|
|
251
|
-
<td>-</td>
|
|
252
|
-
<td>-</td>
|
|
253
|
-
<td>-</td>
|
|
254
|
-
</tr>
|
|
255
|
-
<tr>
|
|
256
|
-
<td>BST<K, V></td>
|
|
257
|
-
<td>-</td>
|
|
258
|
-
<td>-</td>
|
|
259
|
-
<td>-</td>
|
|
260
|
-
</tr>
|
|
261
|
-
<tr>
|
|
262
|
-
<td>RedBlackTree<E></td>
|
|
263
|
-
<td>set<T></td>
|
|
264
|
-
<td>TreeSet<E></td>
|
|
265
|
-
<td>-</td>
|
|
266
|
-
</tr>
|
|
267
|
-
<tr>
|
|
268
|
-
<td>RedBlackTree<K, V></td>
|
|
269
|
-
<td>map<K, V></td>
|
|
270
|
-
<td>TreeMap<K, V></td>
|
|
271
|
-
<td>-</td>
|
|
272
|
-
</tr>
|
|
273
|
-
<tr>
|
|
274
|
-
<td>TreeMultimap<K, V></td>
|
|
275
|
-
<td>multimap<K, V></td>
|
|
276
|
-
<td>-</td>
|
|
277
|
-
<td>-</td>
|
|
278
|
-
</tr>
|
|
279
|
-
<tr>
|
|
280
|
-
<td>-</td>
|
|
281
|
-
<td>multiset<T></td>
|
|
282
|
-
<td>-</td>
|
|
283
|
-
<td>-</td>
|
|
284
|
-
</tr>
|
|
285
|
-
<tr>
|
|
286
|
-
<td>Trie</td>
|
|
287
|
-
<td>-</td>
|
|
288
|
-
<td>-</td>
|
|
289
|
-
<td>-</td>
|
|
290
|
-
</tr>
|
|
291
93
|
<tr>
|
|
292
94
|
<td>DirectedGraph<V, E></td>
|
|
293
95
|
<td>-</td>
|
|
294
96
|
<td>-</td>
|
|
295
97
|
<td>-</td>
|
|
296
98
|
</tr>
|
|
297
|
-
<tr>
|
|
298
|
-
<td>UndirectedGraph<V, E></td>
|
|
299
|
-
<td>-</td>
|
|
300
|
-
<td>-</td>
|
|
301
|
-
<td>-</td>
|
|
302
|
-
</tr>
|
|
303
|
-
<tr>
|
|
304
|
-
<td>PriorityQueue<E></td>
|
|
305
|
-
<td>priority_queue<T></td>
|
|
306
|
-
<td>PriorityQueue<E></td>
|
|
307
|
-
<td>-</td>
|
|
308
|
-
</tr>
|
|
309
|
-
<tr>
|
|
310
|
-
<td>Array<E></td>
|
|
311
|
-
<td>vector<T></td>
|
|
312
|
-
<td>ArrayList<E></td>
|
|
313
|
-
<td>list</td>
|
|
314
|
-
</tr>
|
|
315
|
-
<tr>
|
|
316
|
-
<td>Stack<E></td>
|
|
317
|
-
<td>stack<T></td>
|
|
318
|
-
<td>Stack<E></td>
|
|
319
|
-
<td>-</td>
|
|
320
|
-
</tr>
|
|
321
|
-
<tr>
|
|
322
|
-
<td>Set<E></td>
|
|
323
|
-
<td>-</td>
|
|
324
|
-
<td>HashSet<E></td>
|
|
325
|
-
<td>set</td>
|
|
326
|
-
</tr>
|
|
327
|
-
<tr>
|
|
328
|
-
<td>Map<K, V></td>
|
|
329
|
-
<td>-</td>
|
|
330
|
-
<td>HashMap<K, V></td>
|
|
331
|
-
<td>dict</td>
|
|
332
|
-
</tr>
|
|
333
|
-
<tr>
|
|
334
|
-
<td>-</td>
|
|
335
|
-
<td>unordered_set<T></td>
|
|
336
|
-
<td>HashSet<E></td>
|
|
337
|
-
<td>-</td>
|
|
338
|
-
</tr>
|
|
339
|
-
<tr>
|
|
340
|
-
<td>Map<K, V></td>
|
|
341
|
-
<td>-</td>
|
|
342
|
-
<td>-</td>
|
|
343
|
-
<td>OrderedDict</td>
|
|
344
|
-
</tr>
|
|
345
|
-
<tr>
|
|
346
|
-
<td>-</td>
|
|
347
|
-
<td>unordered_multiset</td>
|
|
348
|
-
<td>-</td>
|
|
349
|
-
<td>Counter</td>
|
|
350
|
-
</tr>
|
|
351
|
-
<tr>
|
|
352
|
-
<td>-</td>
|
|
353
|
-
<td>-</td>
|
|
354
|
-
<td>LinkedHashSet<E></td>
|
|
355
|
-
<td>-</td>
|
|
356
|
-
</tr>
|
|
357
|
-
<tr>
|
|
358
|
-
<td>HashMap<K, V></td>
|
|
359
|
-
<td>-</td>
|
|
360
|
-
<td>LinkedHashMap<K, V></td>
|
|
361
|
-
<td>-</td>
|
|
362
|
-
</tr>
|
|
363
|
-
<tr>
|
|
364
|
-
<td>-</td>
|
|
365
|
-
<td>unordered_multimap<K, V></td>
|
|
366
|
-
<td>-</td>
|
|
367
|
-
<td>-</td>
|
|
368
|
-
</tr>
|
|
369
|
-
<tr>
|
|
370
|
-
<td>-</td>
|
|
371
|
-
<td>bitset<N></td>
|
|
372
|
-
<td>-</td>
|
|
373
|
-
<td>-</td>
|
|
374
|
-
</tr>
|
|
375
99
|
</tbody>
|
|
376
100
|
</table>
|
|
377
101
|
|
|
@@ -379,53 +103,8 @@ yarn add directed-graph-typed
|
|
|
379
103
|
|
|
380
104
|
[//]: # (No deletion!!! Start of Replace Section)
|
|
381
105
|
<div class="json-to-html-collapse clearfix 0">
|
|
382
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>avl-tree</span></div>
|
|
383
|
-
<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.32</td><td>31.93</td><td>3.67e-4</td></tr><tr><td>10,000 add & delete randomly</td><td>70.90</td><td>14.10</td><td>0.00</td></tr><tr><td>10,000 addMany</td><td>40.58</td><td>24.64</td><td>4.87e-4</td></tr><tr><td>10,000 get</td><td>27.31</td><td>36.62</td><td>2.00e-4</td></tr></table></div>
|
|
384
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
385
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>binary-tree</span></div>
|
|
386
|
-
<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>12.35</td><td>80.99</td><td>7.17e-5</td></tr><tr><td>1,000 add & delete randomly</td><td>15.98</td><td>62.58</td><td>7.98e-4</td></tr><tr><td>1,000 addMany</td><td>10.96</td><td>91.27</td><td>0.00</td></tr><tr><td>1,000 get</td><td>18.61</td><td>53.73</td><td>0.00</td></tr><tr><td>1,000 dfs</td><td>164.20</td><td>6.09</td><td>0.04</td></tr><tr><td>1,000 bfs</td><td>58.84</td><td>17.00</td><td>0.01</td></tr><tr><td>1,000 morris</td><td>256.66</td><td>3.90</td><td>7.70e-4</td></tr></table></div>
|
|
387
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
388
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>bst</span></div>
|
|
389
|
-
<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.59</td><td>31.66</td><td>2.74e-4</td></tr><tr><td>10,000 add & delete randomly</td><td>74.56</td><td>13.41</td><td>8.32e-4</td></tr><tr><td>10,000 addMany</td><td>29.16</td><td>34.30</td><td>0.00</td></tr><tr><td>10,000 get</td><td>29.24</td><td>34.21</td><td>0.00</td></tr></table></div>
|
|
390
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
391
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>rb-tree</span></div>
|
|
392
|
-
<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>85.85</td><td>11.65</td><td>0.00</td></tr><tr><td>100,000 add & delete randomly</td><td>211.54</td><td>4.73</td><td>0.00</td></tr><tr><td>100,000 getNode</td><td>37.92</td><td>26.37</td><td>1.65e-4</td></tr></table></div>
|
|
393
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
394
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>comparison</span></div>
|
|
395
|
-
<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>SRC PQ 10,000 add</td><td>0.57</td><td>1748.73</td><td>4.96e-6</td></tr><tr><td>CJS PQ 10,000 add</td><td>0.57</td><td>1746.69</td><td>4.91e-6</td></tr><tr><td>MJS PQ 10,000 add</td><td>0.57</td><td>1749.68</td><td>4.43e-6</td></tr><tr><td>SRC PQ 10,000 add & pop</td><td>3.47</td><td>288.14</td><td>6.38e-4</td></tr><tr><td>CJS PQ 10,000 add & pop</td><td>3.39</td><td>295.36</td><td>3.90e-5</td></tr><tr><td>MJS PQ 10,000 add & pop</td><td>3.37</td><td>297.17</td><td>3.03e-5</td></tr></table></div>
|
|
396
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
397
106
|
<div class='collapsible level0' ><span class='json-to-html-label'>directed-graph</span></div>
|
|
398
107
|
<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>9534.93</td><td>8.72e-7</td></tr><tr><td>1,000 addEdge</td><td>6.30</td><td>158.67</td><td>0.00</td></tr><tr><td>1,000 getVertex</td><td>0.05</td><td>2.16e+4</td><td>3.03e-7</td></tr><tr><td>1,000 getEdge</td><td>22.31</td><td>44.82</td><td>0.00</td></tr><tr><td>tarjan</td><td>210.90</td><td>4.74</td><td>0.01</td></tr><tr><td>tarjan all</td><td>214.72</td><td>4.66</td><td>0.01</td></tr><tr><td>topologicalSort</td><td>172.52</td><td>5.80</td><td>0.00</td></tr></table></div>
|
|
399
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
400
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>hash-map</span></div>
|
|
401
|
-
<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>275.88</td><td>3.62</td><td>0.12</td></tr><tr><td>1,000,000 Map set</td><td>211.66</td><td>4.72</td><td>0.01</td></tr><tr><td>1,000,000 Set add</td><td>177.72</td><td>5.63</td><td>0.02</td></tr><tr><td>1,000,000 set & get</td><td>317.60</td><td>3.15</td><td>0.02</td></tr><tr><td>1,000,000 Map set & get</td><td>274.99</td><td>3.64</td><td>0.03</td></tr><tr><td>1,000,000 Set add & has</td><td>172.23</td><td>5.81</td><td>0.02</td></tr><tr><td>1,000,000 ObjKey set & get</td><td>929.40</td><td>1.08</td><td>0.07</td></tr><tr><td>1,000,000 Map ObjKey set & get</td><td>310.02</td><td>3.23</td><td>0.05</td></tr><tr><td>1,000,000 Set ObjKey add & has</td><td>283.28</td><td>3.53</td><td>0.04</td></tr></table></div>
|
|
402
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
403
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>heap</span></div>
|
|
404
|
-
<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>5.80</td><td>172.35</td><td>8.78e-5</td></tr><tr><td>10,000 fib add & pop</td><td>357.92</td><td>2.79</td><td>0.00</td></tr></table></div>
|
|
405
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
406
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>doubly-linked-list</span></div>
|
|
407
|
-
<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>221.57</td><td>4.51</td><td>0.03</td></tr><tr><td>1,000,000 unshift</td><td>229.02</td><td>4.37</td><td>0.07</td></tr><tr><td>1,000,000 unshift & shift</td><td>169.21</td><td>5.91</td><td>0.02</td></tr><tr><td>1,000,000 insertBefore</td><td>314.48</td><td>3.18</td><td>0.07</td></tr></table></div>
|
|
408
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
409
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>singly-linked-list</span></div>
|
|
410
|
-
<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>212.98</td><td>4.70</td><td>0.01</td></tr><tr><td>10,000 insertBefore</td><td>250.68</td><td>3.99</td><td>0.01</td></tr></table></div>
|
|
411
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
412
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>max-priority-queue</span></div>
|
|
413
|
-
<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>8.91</td><td>112.29</td><td>2.26e-4</td></tr></table></div>
|
|
414
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
415
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>priority-queue</span></div>
|
|
416
|
-
<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 & pop</td><td>103.59</td><td>9.65</td><td>0.00</td></tr></table></div>
|
|
417
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
418
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>deque</span></div>
|
|
419
|
-
<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>14.55</td><td>68.72</td><td>6.91e-4</td></tr><tr><td>1,000,000 push & pop</td><td>23.40</td><td>42.73</td><td>5.94e-4</td></tr><tr><td>1,000,000 push & shift</td><td>24.41</td><td>40.97</td><td>1.45e-4</td></tr><tr><td>1,000,000 unshift & shift</td><td>22.56</td><td>44.32</td><td>1.30e-4</td></tr></table></div>
|
|
420
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
421
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>queue</span></div>
|
|
422
|
-
<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>39.90</td><td>25.07</td><td>0.01</td></tr><tr><td>1,000,000 push & shift</td><td>81.79</td><td>12.23</td><td>0.00</td></tr></table></div>
|
|
423
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
424
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>stack</span></div>
|
|
425
|
-
<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>37.60</td><td>26.60</td><td>0.00</td></tr><tr><td>1,000,000 push & pop</td><td>47.01</td><td>21.27</td><td>0.00</td></tr></table></div>
|
|
426
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
427
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>trie</span></div>
|
|
428
|
-
<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>45.97</td><td>21.76</td><td>0.00</td></tr><tr><td>100,000 getWords</td><td>66.20</td><td>15.11</td><td>0.00</td></tr></table></div>
|
|
429
108
|
</div>
|
|
430
109
|
|
|
431
110
|
[//]: # (No deletion!!! End of Replace Section)
|
|
@@ -441,20 +120,6 @@ yarn add directed-graph-typed
|
|
|
441
120
|
</tr>
|
|
442
121
|
</thead>
|
|
443
122
|
<tbody>
|
|
444
|
-
<tr>
|
|
445
|
-
<td>Binary Tree DFS</td>
|
|
446
|
-
<td>Traverse a binary tree in a depth-first manner, starting from the root node, first visiting the left subtree,
|
|
447
|
-
and then the right subtree, using recursion.
|
|
448
|
-
</td>
|
|
449
|
-
<td>Recursion + Iteration</td>
|
|
450
|
-
</tr>
|
|
451
|
-
<tr>
|
|
452
|
-
<td>Binary Tree BFS</td>
|
|
453
|
-
<td>Traverse a binary tree in a breadth-first manner, starting from the root node, visiting nodes level by level
|
|
454
|
-
from left to right.
|
|
455
|
-
</td>
|
|
456
|
-
<td>Iteration</td>
|
|
457
|
-
</tr>
|
|
458
123
|
<tr>
|
|
459
124
|
<td>Graph DFS</td>
|
|
460
125
|
<td>Traverse a graph in a depth-first manner, starting from a given node, exploring along one path as deeply as
|
|
@@ -462,13 +127,6 @@ yarn add directed-graph-typed
|
|
|
462
127
|
</td>
|
|
463
128
|
<td>Recursion + Iteration</td>
|
|
464
129
|
</tr>
|
|
465
|
-
<tr>
|
|
466
|
-
<td>Binary Tree Morris</td>
|
|
467
|
-
<td>Morris traversal is an in-order traversal algorithm for binary trees with O(1) space complexity. It allows tree
|
|
468
|
-
traversal without additional stack or recursion.
|
|
469
|
-
</td>
|
|
470
|
-
<td>Iteration</td>
|
|
471
|
-
</tr>
|
|
472
130
|
<tr>
|
|
473
131
|
<td>Graph BFS</td>
|
|
474
132
|
<td>Traverse a graph in a breadth-first manner, starting from a given node, first visiting nodes directly connected
|
|
@@ -266,9 +266,9 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
266
266
|
* @returns a boolean value.
|
|
267
267
|
*/
|
|
268
268
|
isRealNode(node) {
|
|
269
|
-
if (
|
|
269
|
+
if (node === this.NIL || node === null || node === undefined)
|
|
270
270
|
return false;
|
|
271
|
-
return
|
|
271
|
+
return this.isNode(node);
|
|
272
272
|
}
|
|
273
273
|
/**
|
|
274
274
|
* The function checks if a given node is a BinaryTreeNode instance and has a key value of NaN.
|
|
@@ -608,7 +608,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
608
608
|
if (!current)
|
|
609
609
|
return undefined;
|
|
610
610
|
if (this._variant === 'STANDARD') {
|
|
611
|
-
// For
|
|
611
|
+
// For 'STANDARD', find the rightmost node
|
|
612
612
|
while (current.right !== undefined) {
|
|
613
613
|
current = current.right;
|
|
614
614
|
}
|
|
@@ -4,9 +4,9 @@ export * from './stack';
|
|
|
4
4
|
export * from './queue';
|
|
5
5
|
export * from './graph';
|
|
6
6
|
export * from './binary-tree';
|
|
7
|
-
export * from './tree';
|
|
8
7
|
export * from './heap';
|
|
9
8
|
export * from './priority-queue';
|
|
10
9
|
export * from './matrix';
|
|
11
10
|
export * from './trie';
|
|
12
11
|
export * from './base';
|
|
12
|
+
export * from './tree';
|
|
@@ -20,9 +20,9 @@ __exportStar(require("./stack"), exports);
|
|
|
20
20
|
__exportStar(require("./queue"), exports);
|
|
21
21
|
__exportStar(require("./graph"), exports);
|
|
22
22
|
__exportStar(require("./binary-tree"), exports);
|
|
23
|
-
__exportStar(require("./tree"), exports);
|
|
24
23
|
__exportStar(require("./heap"), exports);
|
|
25
24
|
__exportStar(require("./priority-queue"), exports);
|
|
26
25
|
__exportStar(require("./matrix"), exports);
|
|
27
26
|
__exportStar(require("./trie"), exports);
|
|
28
27
|
__exportStar(require("./base"), exports);
|
|
28
|
+
__exportStar(require("./tree"), exports);
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toBinaryString(num: number, digit?: number): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toBinaryString = void 0;
|
|
4
|
+
function toBinaryString(num, digit = 32) {
|
|
5
|
+
// Convert number to binary string
|
|
6
|
+
let binaryString = (num >>> 0).toString(2); // Use the unsigned right shift operator to ensure you get a binary representation of a 32-bit unsigned integer
|
|
7
|
+
// Use pad Start to ensure the string length is 32 bits
|
|
8
|
+
binaryString = binaryString.padStart(digit, '0');
|
|
9
|
+
return binaryString;
|
|
10
|
+
}
|
|
11
|
+
exports.toBinaryString = toBinaryString;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "directed-graph-typed",
|
|
3
|
-
"version": "1.51.
|
|
3
|
+
"version": "1.51.4",
|
|
4
4
|
"description": "Directed Graph. Javascript & Typescript Data Structure.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -147,6 +147,6 @@
|
|
|
147
147
|
"typescript": "^4.9.5"
|
|
148
148
|
},
|
|
149
149
|
"dependencies": {
|
|
150
|
-
"data-structure-typed": "^1.51.
|
|
150
|
+
"data-structure-typed": "^1.51.4"
|
|
151
151
|
}
|
|
152
152
|
}
|
|
@@ -316,8 +316,8 @@ export class BinaryTree<
|
|
|
316
316
|
* @returns a boolean value.
|
|
317
317
|
*/
|
|
318
318
|
isRealNode(node: KeyOrNodeOrEntry<K, V, NODE>): node is NODE {
|
|
319
|
-
if (
|
|
320
|
-
return
|
|
319
|
+
if (node === this.NIL || node === null || node === undefined) return false;
|
|
320
|
+
return this.isNode(node);
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
/**
|
|
@@ -695,7 +695,7 @@ export class BST<
|
|
|
695
695
|
if (!current) return undefined;
|
|
696
696
|
|
|
697
697
|
if (this._variant === 'STANDARD') {
|
|
698
|
-
// For
|
|
698
|
+
// For 'STANDARD', find the rightmost node
|
|
699
699
|
while (current.right !== undefined) {
|
|
700
700
|
current = current.right;
|
|
701
701
|
}
|
|
@@ -4,9 +4,9 @@ export * from './stack';
|
|
|
4
4
|
export * from './queue';
|
|
5
5
|
export * from './graph';
|
|
6
6
|
export * from './binary-tree';
|
|
7
|
-
export * from './tree';
|
|
8
7
|
export * from './heap';
|
|
9
8
|
export * from './priority-queue';
|
|
10
9
|
export * from './matrix';
|
|
11
10
|
export * from './trie';
|
|
12
11
|
export * from './base';
|
|
12
|
+
export * from './tree';
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function toBinaryString(num: number, digit = 32) {
|
|
2
|
+
// Convert number to binary string
|
|
3
|
+
let binaryString = (num >>> 0).toString(2); // Use the unsigned right shift operator to ensure you get a binary representation of a 32-bit unsigned integer
|
|
4
|
+
|
|
5
|
+
// Use pad Start to ensure the string length is 32 bits
|
|
6
|
+
binaryString = binaryString.padStart(digit, '0');
|
|
7
|
+
|
|
8
|
+
return binaryString;
|
|
9
|
+
}
|