queue-typed 1.51.3 → 1.51.5
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 +5 -408
- 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
|
@@ -120,132 +120,14 @@ for (let i = 0; i < magnitude; i++) {
|
|
|
120
120
|
</tr>
|
|
121
121
|
</thead>
|
|
122
122
|
<tbody>
|
|
123
|
-
|
|
124
|
-
<td>Binary Tree</td>
|
|
125
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
126
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
127
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html"><span>Binary Tree</span></a></td>
|
|
128
|
-
</tr>
|
|
129
|
-
<tr>
|
|
130
|
-
<td>Binary Search Tree (BST)</td>
|
|
131
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
132
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
133
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BST.html"><span>BST</span></a></td>
|
|
134
|
-
</tr>
|
|
135
|
-
<tr>
|
|
136
|
-
<td>AVL Tree</td>
|
|
137
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
138
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
139
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTree.html"><span>AVLTree</span></a></td>
|
|
140
|
-
</tr>
|
|
141
|
-
<tr>
|
|
142
|
-
<td>Red Black Tree</td>
|
|
143
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
144
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
145
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/RedBlackTree.html"><span>RedBlackTree</span></a></td>
|
|
146
|
-
</tr>
|
|
147
|
-
<tr>
|
|
148
|
-
<td>Tree Multiset</td>
|
|
149
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
150
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
151
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/TreeMultimap.html"><span>TreeMultimap</span></a></td>
|
|
152
|
-
</tr>
|
|
153
|
-
<tr>
|
|
154
|
-
<td>Segment Tree</td>
|
|
155
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
156
|
-
<td></td>
|
|
157
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTree.html"><span>SegmentTree</span></a></td>
|
|
158
|
-
</tr>
|
|
159
|
-
<tr>
|
|
160
|
-
<td>Binary Indexed Tree</td>
|
|
161
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
162
|
-
<td></td>
|
|
163
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryIndexedTree.html"><span>BinaryIndexedTree</span></a></td>
|
|
164
|
-
</tr>
|
|
165
|
-
<tr>
|
|
166
|
-
<td>Heap</td>
|
|
167
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
168
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
169
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Heap.html"><span>Heap</span></a></td>
|
|
170
|
-
</tr>
|
|
171
|
-
<tr>
|
|
172
|
-
<td>Priority Queue</td>
|
|
173
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
174
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
175
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/PriorityQueue.html"><span>PriorityQueue</span></a></td>
|
|
176
|
-
</tr>
|
|
177
|
-
<tr>
|
|
178
|
-
<td>Max Priority Queue</td>
|
|
179
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
180
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
181
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/MaxPriorityQueue.html"><span>MaxPriorityQueue</span></a></td>
|
|
182
|
-
</tr>
|
|
183
|
-
<tr>
|
|
184
|
-
<td>Min Priority Queue</td>
|
|
185
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
186
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
187
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/MinPriorityQueue.html"><span>MinPriorityQueue</span></a></td>
|
|
188
|
-
</tr>
|
|
189
|
-
<tr>
|
|
190
|
-
<td>Trie</td>
|
|
191
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
192
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
193
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Trie.html"><span>Trie</span></a></td>
|
|
194
|
-
</tr>
|
|
195
|
-
<tr>
|
|
196
|
-
<td>Graph</td>
|
|
197
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
198
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
199
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractGraph.html"><span>AbstractGraph</span></a></td>
|
|
200
|
-
</tr>
|
|
201
|
-
<tr>
|
|
202
|
-
<td>Directed Graph</td>
|
|
203
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
204
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
205
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedGraph.html"><span>DirectedGraph</span></a></td>
|
|
206
|
-
</tr>
|
|
207
|
-
<tr>
|
|
208
|
-
<td>Undirected Graph</td>
|
|
209
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
210
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
211
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedGraph.html"><span>UndirectedGraph</span></a></td>
|
|
212
|
-
</tr>
|
|
123
|
+
|
|
213
124
|
<tr>
|
|
214
125
|
<td>Queue</td>
|
|
215
126
|
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
216
127
|
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
217
128
|
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Queue.html"><span>Queue</span></a></td>
|
|
218
129
|
</tr>
|
|
219
|
-
|
|
220
|
-
<td>Deque</td>
|
|
221
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
222
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
223
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Deque.html"><span>Deque</span></a></td>
|
|
224
|
-
</tr>
|
|
225
|
-
<tr>
|
|
226
|
-
<td>Linked List</td>
|
|
227
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
228
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
229
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>SinglyLinkedList</span></a></td>
|
|
230
|
-
</tr>
|
|
231
|
-
<tr>
|
|
232
|
-
<td>Singly Linked List</td>
|
|
233
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
234
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
235
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>SinglyLinkedList</span></a></td>
|
|
236
|
-
</tr>
|
|
237
|
-
<tr>
|
|
238
|
-
<td>Doubly Linked List</td>
|
|
239
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
240
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
241
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedList.html"><span>DoublyLinkedList</span></a></td>
|
|
242
|
-
</tr>
|
|
243
|
-
<tr>
|
|
244
|
-
<td>Stack</td>
|
|
245
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
246
|
-
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
|
|
247
|
-
<td><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html"><span>Stack</span></a></td>
|
|
248
|
-
</tr>
|
|
130
|
+
|
|
249
131
|
</tbody>
|
|
250
132
|
</table>
|
|
251
133
|
|
|
@@ -261,168 +143,14 @@ for (let i = 0; i < magnitude; i++) {
|
|
|
261
143
|
</tr>
|
|
262
144
|
</thead>
|
|
263
145
|
<tbody>
|
|
264
|
-
|
|
265
|
-
<td>Heap<E></td>
|
|
266
|
-
<td>priority_queue<T></td>
|
|
267
|
-
<td>PriorityQueue<E></td>
|
|
268
|
-
<td>heapq</td>
|
|
269
|
-
</tr>
|
|
270
|
-
<tr>
|
|
271
|
-
<td>Deque<E></td>
|
|
272
|
-
<td>deque<T></td>
|
|
273
|
-
<td>ArrayDeque<E></td>
|
|
274
|
-
<td>deque</td>
|
|
275
|
-
</tr>
|
|
146
|
+
|
|
276
147
|
<tr>
|
|
277
148
|
<td>Queue<E></td>
|
|
278
149
|
<td>queue<T></td>
|
|
279
150
|
<td>Queue<E></td>
|
|
280
151
|
<td>-</td>
|
|
281
152
|
</tr>
|
|
282
|
-
|
|
283
|
-
<td>HashMap<K, V></td>
|
|
284
|
-
<td>unordered_map<K, V></td>
|
|
285
|
-
<td>HashMap<K, V></td>
|
|
286
|
-
<td>defaultdict</td>
|
|
287
|
-
</tr>
|
|
288
|
-
<tr>
|
|
289
|
-
<td>DoublyLinkedList<E></td>
|
|
290
|
-
<td>list<T></td>
|
|
291
|
-
<td>LinkedList<E></td>
|
|
292
|
-
<td>-</td>
|
|
293
|
-
</tr>
|
|
294
|
-
<tr>
|
|
295
|
-
<td>SinglyLinkedList<E></td>
|
|
296
|
-
<td>-</td>
|
|
297
|
-
<td>-</td>
|
|
298
|
-
<td>-</td>
|
|
299
|
-
</tr>
|
|
300
|
-
<tr>
|
|
301
|
-
<td>BinaryTree<K, V></td>
|
|
302
|
-
<td>-</td>
|
|
303
|
-
<td>-</td>
|
|
304
|
-
<td>-</td>
|
|
305
|
-
</tr>
|
|
306
|
-
<tr>
|
|
307
|
-
<td>BST<K, V></td>
|
|
308
|
-
<td>-</td>
|
|
309
|
-
<td>-</td>
|
|
310
|
-
<td>-</td>
|
|
311
|
-
</tr>
|
|
312
|
-
<tr>
|
|
313
|
-
<td>RedBlackTree<E></td>
|
|
314
|
-
<td>set<T></td>
|
|
315
|
-
<td>TreeSet<E></td>
|
|
316
|
-
<td>-</td>
|
|
317
|
-
</tr>
|
|
318
|
-
<tr>
|
|
319
|
-
<td>RedBlackTree<K, V></td>
|
|
320
|
-
<td>map<K, V></td>
|
|
321
|
-
<td>TreeMap<K, V></td>
|
|
322
|
-
<td>-</td>
|
|
323
|
-
</tr>
|
|
324
|
-
<tr>
|
|
325
|
-
<td>TreeMultimap<K, V></td>
|
|
326
|
-
<td>multimap<K, V></td>
|
|
327
|
-
<td>-</td>
|
|
328
|
-
<td>-</td>
|
|
329
|
-
</tr>
|
|
330
|
-
<tr>
|
|
331
|
-
<td>-</td>
|
|
332
|
-
<td>multiset<T></td>
|
|
333
|
-
<td>-</td>
|
|
334
|
-
<td>-</td>
|
|
335
|
-
</tr>
|
|
336
|
-
<tr>
|
|
337
|
-
<td>Trie</td>
|
|
338
|
-
<td>-</td>
|
|
339
|
-
<td>-</td>
|
|
340
|
-
<td>-</td>
|
|
341
|
-
</tr>
|
|
342
|
-
<tr>
|
|
343
|
-
<td>DirectedGraph<V, E></td>
|
|
344
|
-
<td>-</td>
|
|
345
|
-
<td>-</td>
|
|
346
|
-
<td>-</td>
|
|
347
|
-
</tr>
|
|
348
|
-
<tr>
|
|
349
|
-
<td>UndirectedGraph<V, E></td>
|
|
350
|
-
<td>-</td>
|
|
351
|
-
<td>-</td>
|
|
352
|
-
<td>-</td>
|
|
353
|
-
</tr>
|
|
354
|
-
<tr>
|
|
355
|
-
<td>PriorityQueue<E></td>
|
|
356
|
-
<td>priority_queue<T></td>
|
|
357
|
-
<td>PriorityQueue<E></td>
|
|
358
|
-
<td>-</td>
|
|
359
|
-
</tr>
|
|
360
|
-
<tr>
|
|
361
|
-
<td>Array<E></td>
|
|
362
|
-
<td>vector<T></td>
|
|
363
|
-
<td>ArrayList<E></td>
|
|
364
|
-
<td>list</td>
|
|
365
|
-
</tr>
|
|
366
|
-
<tr>
|
|
367
|
-
<td>Stack<E></td>
|
|
368
|
-
<td>stack<T></td>
|
|
369
|
-
<td>Stack<E></td>
|
|
370
|
-
<td>-</td>
|
|
371
|
-
</tr>
|
|
372
|
-
<tr>
|
|
373
|
-
<td>Set<E></td>
|
|
374
|
-
<td>-</td>
|
|
375
|
-
<td>HashSet<E></td>
|
|
376
|
-
<td>set</td>
|
|
377
|
-
</tr>
|
|
378
|
-
<tr>
|
|
379
|
-
<td>Map<K, V></td>
|
|
380
|
-
<td>-</td>
|
|
381
|
-
<td>HashMap<K, V></td>
|
|
382
|
-
<td>dict</td>
|
|
383
|
-
</tr>
|
|
384
|
-
<tr>
|
|
385
|
-
<td>-</td>
|
|
386
|
-
<td>unordered_set<T></td>
|
|
387
|
-
<td>HashSet<E></td>
|
|
388
|
-
<td>-</td>
|
|
389
|
-
</tr>
|
|
390
|
-
<tr>
|
|
391
|
-
<td>Map<K, V></td>
|
|
392
|
-
<td>-</td>
|
|
393
|
-
<td>-</td>
|
|
394
|
-
<td>OrderedDict</td>
|
|
395
|
-
</tr>
|
|
396
|
-
<tr>
|
|
397
|
-
<td>-</td>
|
|
398
|
-
<td>unordered_multiset</td>
|
|
399
|
-
<td>-</td>
|
|
400
|
-
<td>Counter</td>
|
|
401
|
-
</tr>
|
|
402
|
-
<tr>
|
|
403
|
-
<td>-</td>
|
|
404
|
-
<td>-</td>
|
|
405
|
-
<td>LinkedHashSet<E></td>
|
|
406
|
-
<td>-</td>
|
|
407
|
-
</tr>
|
|
408
|
-
<tr>
|
|
409
|
-
<td>HashMap<K, V></td>
|
|
410
|
-
<td>-</td>
|
|
411
|
-
<td>LinkedHashMap<K, V></td>
|
|
412
|
-
<td>-</td>
|
|
413
|
-
</tr>
|
|
414
|
-
<tr>
|
|
415
|
-
<td>-</td>
|
|
416
|
-
<td>unordered_multimap<K, V></td>
|
|
417
|
-
<td>-</td>
|
|
418
|
-
<td>-</td>
|
|
419
|
-
</tr>
|
|
420
|
-
<tr>
|
|
421
|
-
<td>-</td>
|
|
422
|
-
<td>bitset<N></td>
|
|
423
|
-
<td>-</td>
|
|
424
|
-
<td>-</td>
|
|
425
|
-
</tr>
|
|
153
|
+
|
|
426
154
|
</tbody>
|
|
427
155
|
</table>
|
|
428
156
|
|
|
@@ -430,53 +158,8 @@ for (let i = 0; i < magnitude; i++) {
|
|
|
430
158
|
|
|
431
159
|
[//]: # (No deletion!!! Start of Replace Section)
|
|
432
160
|
<div class="json-to-html-collapse clearfix 0">
|
|
433
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>avl-tree</span></div>
|
|
434
|
-
<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>
|
|
435
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
436
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>binary-tree</span></div>
|
|
437
|
-
<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>
|
|
438
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
439
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>bst</span></div>
|
|
440
|
-
<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>
|
|
441
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
442
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>rb-tree</span></div>
|
|
443
|
-
<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>
|
|
444
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
445
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>comparison</span></div>
|
|
446
|
-
<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>
|
|
447
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
448
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>directed-graph</span></div>
|
|
449
|
-
<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>
|
|
450
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
451
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>hash-map</span></div>
|
|
452
|
-
<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>
|
|
453
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
454
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>heap</span></div>
|
|
455
|
-
<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>
|
|
456
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
457
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>doubly-linked-list</span></div>
|
|
458
|
-
<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>
|
|
459
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
460
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>singly-linked-list</span></div>
|
|
461
|
-
<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>
|
|
462
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
463
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>max-priority-queue</span></div>
|
|
464
|
-
<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>
|
|
465
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
466
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>priority-queue</span></div>
|
|
467
|
-
<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>
|
|
468
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
469
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>deque</span></div>
|
|
470
|
-
<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>
|
|
471
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
472
161
|
<div class='collapsible level0' ><span class='json-to-html-label'>queue</span></div>
|
|
473
162
|
<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>
|
|
474
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
475
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>stack</span></div>
|
|
476
|
-
<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>
|
|
477
|
-
</div><div class="json-to-html-collapse clearfix 0">
|
|
478
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>trie</span></div>
|
|
479
|
-
<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>
|
|
480
163
|
</div>
|
|
481
164
|
|
|
482
165
|
[//]: # (No deletion!!! End of Replace Section)
|
|
@@ -492,93 +175,7 @@ for (let i = 0; i < magnitude; i++) {
|
|
|
492
175
|
</tr>
|
|
493
176
|
</thead>
|
|
494
177
|
<tbody>
|
|
495
|
-
|
|
496
|
-
<td>Binary Tree DFS</td>
|
|
497
|
-
<td>Traverse a binary tree in a depth-first manner, starting from the root node, first visiting the left subtree,
|
|
498
|
-
and then the right subtree, using recursion.
|
|
499
|
-
</td>
|
|
500
|
-
<td>Recursion + Iteration</td>
|
|
501
|
-
</tr>
|
|
502
|
-
<tr>
|
|
503
|
-
<td>Binary Tree BFS</td>
|
|
504
|
-
<td>Traverse a binary tree in a breadth-first manner, starting from the root node, visiting nodes level by level
|
|
505
|
-
from left to right.
|
|
506
|
-
</td>
|
|
507
|
-
<td>Iteration</td>
|
|
508
|
-
</tr>
|
|
509
|
-
<tr>
|
|
510
|
-
<td>Graph DFS</td>
|
|
511
|
-
<td>Traverse a graph in a depth-first manner, starting from a given node, exploring along one path as deeply as
|
|
512
|
-
possible, and backtracking to explore other paths. Used for finding connected components, paths, etc.
|
|
513
|
-
</td>
|
|
514
|
-
<td>Recursion + Iteration</td>
|
|
515
|
-
</tr>
|
|
516
|
-
<tr>
|
|
517
|
-
<td>Binary Tree Morris</td>
|
|
518
|
-
<td>Morris traversal is an in-order traversal algorithm for binary trees with O(1) space complexity. It allows tree
|
|
519
|
-
traversal without additional stack or recursion.
|
|
520
|
-
</td>
|
|
521
|
-
<td>Iteration</td>
|
|
522
|
-
</tr>
|
|
523
|
-
<tr>
|
|
524
|
-
<td>Graph BFS</td>
|
|
525
|
-
<td>Traverse a graph in a breadth-first manner, starting from a given node, first visiting nodes directly connected
|
|
526
|
-
to the starting node, and then expanding level by level. Used for finding shortest paths, etc.
|
|
527
|
-
</td>
|
|
528
|
-
<td>Recursion + Iteration</td>
|
|
529
|
-
</tr>
|
|
530
|
-
<tr>
|
|
531
|
-
<td>Graph Tarjan's Algorithm</td>
|
|
532
|
-
<td>Find strongly connected components in a graph, typically implemented using depth-first search.</td>
|
|
533
|
-
<td>Recursion</td>
|
|
534
|
-
</tr>
|
|
535
|
-
<tr>
|
|
536
|
-
<td>Graph Bellman-Ford Algorithm</td>
|
|
537
|
-
<td>Finding the shortest paths from a single source, can handle negative weight edges</td>
|
|
538
|
-
<td>Iteration</td>
|
|
539
|
-
</tr>
|
|
540
|
-
<tr>
|
|
541
|
-
<td>Graph Dijkstra's Algorithm</td>
|
|
542
|
-
<td>Finding the shortest paths from a single source, cannot handle negative weight edges</td>
|
|
543
|
-
<td>Iteration</td>
|
|
544
|
-
</tr>
|
|
545
|
-
<tr>
|
|
546
|
-
<td>Graph Floyd-Warshall Algorithm</td>
|
|
547
|
-
<td>Finding the shortest paths between all pairs of nodes</td>
|
|
548
|
-
<td>Iteration</td>
|
|
549
|
-
</tr>
|
|
550
|
-
<tr>
|
|
551
|
-
<td>Graph getCycles</td>
|
|
552
|
-
<td>Find all cycles in a graph or detect the presence of cycles.</td>
|
|
553
|
-
<td>Recursion</td>
|
|
554
|
-
</tr>
|
|
555
|
-
<tr>
|
|
556
|
-
<td>Graph getCutVertexes</td>
|
|
557
|
-
<td>Find cut vertices in a graph, which are nodes that, when removed, increase the number of connected components in
|
|
558
|
-
the graph.
|
|
559
|
-
</td>
|
|
560
|
-
<td>Recursion</td>
|
|
561
|
-
</tr>
|
|
562
|
-
<tr>
|
|
563
|
-
<td>Graph getSCCs</td>
|
|
564
|
-
<td>Find strongly connected components in a graph, which are subgraphs where any two nodes can reach each other.
|
|
565
|
-
</td>
|
|
566
|
-
<td>Recursion</td>
|
|
567
|
-
</tr>
|
|
568
|
-
<tr>
|
|
569
|
-
<td>Graph getBridges</td>
|
|
570
|
-
<td>Find bridges in a graph, which are edges that, when removed, increase the number of connected components in the
|
|
571
|
-
graph.
|
|
572
|
-
</td>
|
|
573
|
-
<td>Recursion</td>
|
|
574
|
-
</tr>
|
|
575
|
-
<tr>
|
|
576
|
-
<td>Graph topologicalSort</td>
|
|
577
|
-
<td>Perform topological sorting on a directed acyclic graph (DAG) to find a linear order of nodes such that all
|
|
578
|
-
directed edges go from earlier nodes to later nodes.
|
|
579
|
-
</td>
|
|
580
|
-
<td>Recursion</td>
|
|
581
|
-
</tr>
|
|
178
|
+
|
|
582
179
|
</tbody>
|
|
583
180
|
</table>
|
|
584
181
|
|
|
@@ -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": "queue-typed",
|
|
3
|
-
"version": "1.51.
|
|
3
|
+
"version": "1.51.5",
|
|
4
4
|
"description": "Queue, ArrayQueue. Javascript & Typescript Data Structure.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -115,6 +115,6 @@
|
|
|
115
115
|
"typescript": "^4.9.5"
|
|
116
116
|
},
|
|
117
117
|
"dependencies": {
|
|
118
|
-
"data-structure-typed": "^1.51.
|
|
118
|
+
"data-structure-typed": "^1.51.5"
|
|
119
119
|
}
|
|
120
120
|
}
|
|
@@ -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
|
+
}
|