data-structure-typed 1.54.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/benchmark/report.html +26 -2
  3. package/benchmark/report.json +292 -42
  4. package/dist/cjs/data-structures/base/iterable-element-base.d.ts +14 -40
  5. package/dist/cjs/data-structures/base/iterable-element-base.js +14 -11
  6. package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -1
  7. package/dist/cjs/data-structures/base/linear-base.d.ts +277 -0
  8. package/dist/cjs/data-structures/base/linear-base.js +553 -0
  9. package/dist/cjs/data-structures/base/linear-base.js.map +1 -0
  10. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +12 -8
  11. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +50 -37
  12. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  13. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +64 -0
  14. package/dist/cjs/data-structures/binary-tree/avl-tree.js +64 -0
  15. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  16. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +62 -0
  17. package/dist/cjs/data-structures/binary-tree/binary-tree.js +67 -5
  18. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  19. package/dist/cjs/data-structures/binary-tree/bst.d.ts +3 -3
  20. package/dist/cjs/data-structures/binary-tree/bst.js +14 -14
  21. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  22. package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +1 -7
  23. package/dist/cjs/data-structures/binary-tree/red-black-tree.js +1 -7
  24. package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
  25. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +175 -14
  26. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +210 -40
  27. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  28. package/dist/cjs/data-structures/graph/abstract-graph.js +2 -2
  29. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  30. package/dist/cjs/data-structures/heap/heap.d.ts +3 -11
  31. package/dist/cjs/data-structures/heap/heap.js +0 -10
  32. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  33. package/dist/cjs/data-structures/heap/max-heap.d.ts +2 -2
  34. package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
  35. package/dist/cjs/data-structures/heap/min-heap.d.ts +2 -2
  36. package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
  37. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +65 -94
  38. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +131 -146
  39. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  40. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +79 -75
  41. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +217 -169
  42. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  43. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +2 -2
  44. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  45. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +2 -2
  46. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  47. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +2 -2
  48. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  49. package/dist/cjs/data-structures/queue/deque.d.ts +130 -91
  50. package/dist/cjs/data-structures/queue/deque.js +269 -169
  51. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  52. package/dist/cjs/data-structures/queue/queue.d.ts +84 -40
  53. package/dist/cjs/data-structures/queue/queue.js +134 -50
  54. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  55. package/dist/cjs/data-structures/stack/stack.d.ts +3 -11
  56. package/dist/cjs/data-structures/stack/stack.js +0 -10
  57. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  58. package/dist/cjs/data-structures/trie/trie.d.ts +4 -3
  59. package/dist/cjs/data-structures/trie/trie.js +3 -0
  60. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  61. package/dist/cjs/types/data-structures/base/base.d.ts +9 -4
  62. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -1
  63. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -1
  64. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
  65. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.d.ts +2 -2
  66. package/dist/cjs/types/data-structures/queue/deque.d.ts +2 -3
  67. package/dist/cjs/types/data-structures/queue/queue.d.ts +2 -2
  68. package/dist/esm/data-structures/base/iterable-element-base.d.ts +14 -40
  69. package/dist/esm/data-structures/base/iterable-element-base.js +14 -11
  70. package/dist/esm/data-structures/base/iterable-element-base.js.map +1 -1
  71. package/dist/esm/data-structures/base/linear-base.d.ts +277 -0
  72. package/dist/esm/data-structures/base/linear-base.js +549 -0
  73. package/dist/esm/data-structures/base/linear-base.js.map +1 -0
  74. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.d.ts +12 -8
  75. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +50 -36
  76. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  77. package/dist/esm/data-structures/binary-tree/avl-tree.d.ts +64 -0
  78. package/dist/esm/data-structures/binary-tree/avl-tree.js +64 -0
  79. package/dist/esm/data-structures/binary-tree/avl-tree.js.map +1 -1
  80. package/dist/esm/data-structures/binary-tree/binary-tree.d.ts +62 -0
  81. package/dist/esm/data-structures/binary-tree/binary-tree.js +67 -5
  82. package/dist/esm/data-structures/binary-tree/binary-tree.js.map +1 -1
  83. package/dist/esm/data-structures/binary-tree/bst.d.ts +3 -3
  84. package/dist/esm/data-structures/binary-tree/bst.js +14 -12
  85. package/dist/esm/data-structures/binary-tree/bst.js.map +1 -1
  86. package/dist/esm/data-structures/binary-tree/red-black-tree.d.ts +1 -7
  87. package/dist/esm/data-structures/binary-tree/red-black-tree.js +1 -7
  88. package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +1 -1
  89. package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +175 -14
  90. package/dist/esm/data-structures/binary-tree/tree-multi-map.js +210 -39
  91. package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  92. package/dist/esm/data-structures/graph/abstract-graph.js +2 -2
  93. package/dist/esm/data-structures/graph/abstract-graph.js.map +1 -1
  94. package/dist/esm/data-structures/heap/heap.d.ts +3 -11
  95. package/dist/esm/data-structures/heap/heap.js +0 -10
  96. package/dist/esm/data-structures/heap/heap.js.map +1 -1
  97. package/dist/esm/data-structures/heap/max-heap.d.ts +2 -2
  98. package/dist/esm/data-structures/heap/max-heap.js.map +1 -1
  99. package/dist/esm/data-structures/heap/min-heap.d.ts +2 -2
  100. package/dist/esm/data-structures/heap/min-heap.js.map +1 -1
  101. package/dist/esm/data-structures/linked-list/doubly-linked-list.d.ts +65 -94
  102. package/dist/esm/data-structures/linked-list/doubly-linked-list.js +132 -148
  103. package/dist/esm/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  104. package/dist/esm/data-structures/linked-list/singly-linked-list.d.ts +79 -75
  105. package/dist/esm/data-structures/linked-list/singly-linked-list.js +217 -170
  106. package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +1 -1
  107. package/dist/esm/data-structures/priority-queue/max-priority-queue.d.ts +2 -2
  108. package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  109. package/dist/esm/data-structures/priority-queue/min-priority-queue.d.ts +2 -2
  110. package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  111. package/dist/esm/data-structures/priority-queue/priority-queue.d.ts +2 -2
  112. package/dist/esm/data-structures/priority-queue/priority-queue.js.map +1 -1
  113. package/dist/esm/data-structures/queue/deque.d.ts +130 -91
  114. package/dist/esm/data-structures/queue/deque.js +269 -169
  115. package/dist/esm/data-structures/queue/deque.js.map +1 -1
  116. package/dist/esm/data-structures/queue/queue.d.ts +84 -40
  117. package/dist/esm/data-structures/queue/queue.js +135 -51
  118. package/dist/esm/data-structures/queue/queue.js.map +1 -1
  119. package/dist/esm/data-structures/stack/stack.d.ts +3 -11
  120. package/dist/esm/data-structures/stack/stack.js +0 -10
  121. package/dist/esm/data-structures/stack/stack.js.map +1 -1
  122. package/dist/esm/data-structures/trie/trie.d.ts +4 -3
  123. package/dist/esm/data-structures/trie/trie.js +3 -0
  124. package/dist/esm/data-structures/trie/trie.js.map +1 -1
  125. package/dist/esm/types/data-structures/base/base.d.ts +9 -4
  126. package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -1
  127. package/dist/esm/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -1
  128. package/dist/esm/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
  129. package/dist/esm/types/data-structures/linked-list/singly-linked-list.d.ts +2 -2
  130. package/dist/esm/types/data-structures/queue/deque.d.ts +2 -3
  131. package/dist/esm/types/data-structures/queue/queue.d.ts +2 -2
  132. package/dist/umd/data-structure-typed.js +1246 -635
  133. package/dist/umd/data-structure-typed.min.js +3 -3
  134. package/dist/umd/data-structure-typed.min.js.map +1 -1
  135. package/package.json +6 -6
  136. package/src/data-structures/base/iterable-element-base.ts +29 -20
  137. package/src/data-structures/base/linear-base.ts +649 -0
  138. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +51 -36
  139. package/src/data-structures/binary-tree/avl-tree.ts +64 -0
  140. package/src/data-structures/binary-tree/binary-tree.ts +5 -5
  141. package/src/data-structures/binary-tree/bst.ts +9 -9
  142. package/src/data-structures/binary-tree/tree-multi-map.ts +214 -40
  143. package/src/data-structures/graph/abstract-graph.ts +2 -2
  144. package/src/data-structures/heap/heap.ts +3 -14
  145. package/src/data-structures/heap/max-heap.ts +2 -2
  146. package/src/data-structures/heap/min-heap.ts +2 -2
  147. package/src/data-structures/linked-list/doubly-linked-list.ts +144 -160
  148. package/src/data-structures/linked-list/singly-linked-list.ts +241 -185
  149. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -5
  150. package/src/data-structures/priority-queue/min-priority-queue.ts +2 -5
  151. package/src/data-structures/priority-queue/priority-queue.ts +2 -2
  152. package/src/data-structures/queue/deque.ts +286 -183
  153. package/src/data-structures/queue/queue.ts +149 -63
  154. package/src/data-structures/stack/stack.ts +3 -18
  155. package/src/data-structures/trie/trie.ts +7 -3
  156. package/src/types/data-structures/base/base.ts +17 -8
  157. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -1
  158. package/src/types/data-structures/binary-tree/tree-multi-map.ts +1 -1
  159. package/src/types/data-structures/linked-list/doubly-linked-list.ts +2 -2
  160. package/src/types/data-structures/linked-list/singly-linked-list.ts +2 -2
  161. package/src/types/data-structures/queue/deque.ts +2 -3
  162. package/src/types/data-structures/queue/queue.ts +2 -2
  163. package/test/integration/all-in-one.test.ts +1 -1
  164. package/test/integration/avl-tree.test.ts +1 -1
  165. package/test/integration/bst.test.ts +2 -2
  166. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +168 -0
  167. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +15 -14
  168. package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +1 -1
  169. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +165 -7
  170. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +135 -27
  171. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +111 -11
  172. package/test/unit/data-structures/queue/deque.test.ts +241 -60
  173. package/test/unit/data-structures/queue/queue.test.ts +118 -19
  174. package/test/unit/unrestricted-interconversion.test.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file.
8
8
  - [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
9
9
  - [`auto-changelog`](https://github.com/CookPete/auto-changelog)
10
10
 
11
- ## [v1.54.3](https://github.com/zrwusa/data-structure-typed/compare/v1.51.5...main) (upcoming)
11
+ ## [v2.0.0](https://github.com/zrwusa/data-structure-typed/compare/v1.51.5...main) (upcoming)
12
12
 
13
13
  ### Changes
14
14
 
@@ -42,11 +42,35 @@
42
42
  </head>
43
43
  <body>
44
44
  <div id="json-to-html"><div class="json-to-html-collapse clearfix 0">
45
+ <div class='collapsible level0' ><span class='json-to-html-label'>heap</span></div>
46
+ <div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>sample mean (secs)</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>6.66</td><td>0.01</td><td>1.93e-4</td></tr><tr><td>100,000 add & poll</td><td>35.36</td><td>0.04</td><td>0.00</td></tr></table></div>
47
+ </div><div class="json-to-html-collapse clearfix 0">
45
48
  <div class='collapsible level0' ><span class='json-to-html-label'>avl-tree</span></div>
46
- <div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>sample mean (secs)</th><th>sample deviation</th></tr><tr><td>100,000 add randomly</td><td>526.46</td><td>0.53</td><td>0.01</td></tr><tr><td>100,000 add</td><td>474.38</td><td>0.47</td><td>0.00</td></tr><tr><td>100,000 get</td><td>0.72</td><td>7.17e-4</td><td>3.47e-4</td></tr><tr><td>100,000 getNode</td><td>252.58</td><td>0.25</td><td>0.01</td></tr><tr><td>100,000 iterator</td><td>24.84</td><td>0.02</td><td>0.00</td></tr><tr><td>100,000 add & delete orderly</td><td>717.48</td><td>0.72</td><td>0.02</td></tr><tr><td>100,000 add & delete randomly</td><td>898.45</td><td>0.90</td><td>0.02</td></tr></table></div>
49
+ <div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>sample mean (secs)</th><th>sample deviation</th></tr><tr><td>100,000 add randomly</td><td>548.16</td><td>0.55</td><td>0.02</td></tr><tr><td>100,000 add</td><td>503.07</td><td>0.50</td><td>0.02</td></tr><tr><td>100,000 get</td><td>0.62</td><td>6.18e-4</td><td>2.45e-4</td></tr><tr><td>100,000 getNode</td><td>326.99</td><td>0.33</td><td>0.00</td></tr><tr><td>100,000 iterator</td><td>32.01</td><td>0.03</td><td>0.00</td></tr><tr><td>100,000 add & delete orderly</td><td>809.71</td><td>0.81</td><td>0.08</td></tr><tr><td>100,000 add & delete randomly</td><td>993.95</td><td>0.99</td><td>0.03</td></tr></table></div>
47
50
  </div><div class="json-to-html-collapse clearfix 0">
48
51
  <div class='collapsible level0' ><span class='json-to-html-label'>red-black-tree</span></div>
49
- <div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>sample mean (secs)</th><th>sample deviation</th></tr><tr><td>100,000 add randomly</td><td>144.49</td><td>0.14</td><td>0.01</td></tr><tr><td>100,000 add</td><td>190.53</td><td>0.19</td><td>0.00</td></tr><tr><td>100,000 get</td><td>0.91</td><td>9.14e-4</td><td>2.11e-4</td></tr><tr><td>100,000 getNode</td><td>323.66</td><td>0.32</td><td>0.00</td></tr><tr><td>100,000 node mode add randomly</td><td>139.71</td><td>0.14</td><td>0.00</td></tr><tr><td>100,000 node mode get</td><td>322.39</td><td>0.32</td><td>7.58e-4</td></tr><tr><td>100,000 iterator</td><td>27.07</td><td>0.03</td><td>0.00</td></tr><tr><td>100,000 add & delete orderly</td><td>349.17</td><td>0.35</td><td>0.00</td></tr><tr><td>100,000 add & delete randomly</td><td>482.61</td><td>0.48</td><td>0.01</td></tr></table></div>
52
+ <div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>sample mean (secs)</th><th>sample deviation</th></tr><tr><td>100,000 add randomly</td><td>159.87</td><td>0.16</td><td>0.00</td></tr><tr><td>100,000 add</td><td>218.47</td><td>0.22</td><td>3.58e-4</td></tr><tr><td>100,000 get</td><td>1.12</td><td>0.00</td><td>1.82e-4</td></tr><tr><td>100,000 getNode</td><td>511.83</td><td>0.51</td><td>0.00</td></tr><tr><td>100,000 node mode add randomly</td><td>156.83</td><td>0.16</td><td>0.00</td></tr><tr><td>100,000 node mode get</td><td>509.76</td><td>0.51</td><td>0.00</td></tr><tr><td>100,000 iterator</td><td>32.75</td><td>0.03</td><td>0.00</td></tr><tr><td>100,000 add & delete orderly</td><td>460.34</td><td>0.46</td><td>0.00</td></tr><tr><td>100,000 add & delete randomly</td><td>679.75</td><td>0.68</td><td>0.04</td></tr></table></div>
53
+ </div><div class="json-to-html-collapse clearfix 0">
54
+ <div class='collapsible level0' ><span class='json-to-html-label'>doubly-linked-list</span></div>
55
+ <div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>sample mean (secs)</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>182.03</td><td>0.18</td><td>0.02</td></tr><tr><td>1,000,000 unshift</td><td>185.94</td><td>0.19</td><td>0.03</td></tr><tr><td>1,000,000 unshift & shift</td><td>159.02</td><td>0.16</td><td>0.03</td></tr><tr><td>1,000,000 addBefore</td><td>252.73</td><td>0.25</td><td>0.03</td></tr></table></div>
56
+ </div><div class="json-to-html-collapse clearfix 0">
57
+ <div class='collapsible level0' ><span class='json-to-html-label'>directed-graph</span></div>
58
+ <div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>sample mean (secs)</th><th>sample deviation</th></tr><tr><td>1,000 addVertex</td><td>0.10</td><td>9.56e-5</td><td>9.71e-7</td></tr><tr><td>1,000 addEdge</td><td>5.97</td><td>0.01</td><td>1.99e-4</td></tr><tr><td>1,000 getVertex</td><td>0.10</td><td>9.71e-5</td><td>1.17e-6</td></tr><tr><td>1,000 getEdge</td><td>23.25</td><td>0.02</td><td>0.00</td></tr><tr><td>tarjan</td><td>192.40</td><td>0.19</td><td>0.00</td></tr><tr><td>topologicalSort</td><td>151.03</td><td>0.15</td><td>0.01</td></tr></table></div>
59
+ </div><div class="json-to-html-collapse clearfix 0">
60
+ <div class='collapsible level0' ><span class='json-to-html-label'>queue</span></div>
61
+ <div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>sample mean (secs)</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>53.79</td><td>0.05</td><td>0.02</td></tr><tr><td>100,000 push & shift</td><td>5.49</td><td>0.01</td><td>0.00</td></tr><tr><td>Native JS Array 100,000 push & shift</td><td>2358.01</td><td>2.36</td><td>0.32</td></tr></table></div>
62
+ </div><div class="json-to-html-collapse clearfix 0">
63
+ <div class='collapsible level0' ><span class='json-to-html-label'>deque</span></div>
64
+ <div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>sample mean (secs)</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>23.74</td><td>0.02</td><td>0.01</td></tr><tr><td>1,000,000 push & pop</td><td>25.37</td><td>0.03</td><td>0.01</td></tr><tr><td>1,000,000 push & shift</td><td>27.61</td><td>0.03</td><td>0.01</td></tr><tr><td>100,000 push & shift</td><td>2.77</td><td>0.00</td><td>0.00</td></tr><tr><td>Native JS Array 100,000 push & shift</td><td>2430.40</td><td>2.43</td><td>0.31</td></tr><tr><td>100,000 unshift & shift</td><td>2.46</td><td>0.00</td><td>8.81e-4</td></tr><tr><td>Native JS Array 100,000 unshift & shift</td><td>4239.82</td><td>4.24</td><td>0.37</td></tr></table></div>
65
+ </div><div class="json-to-html-collapse clearfix 0">
66
+ <div class='collapsible level0' ><span class='json-to-html-label'>hash-map</span></div>
67
+ <div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>sample mean (secs)</th><th>sample deviation</th></tr><tr><td>1,000,000 set</td><td>96.79</td><td>0.10</td><td>0.05</td></tr><tr><td>Native JS Map 1,000,000 set</td><td>230.38</td><td>0.23</td><td>0.05</td></tr><tr><td>Native JS Set 1,000,000 add</td><td>170.58</td><td>0.17</td><td>0.01</td></tr><tr><td>1,000,000 set & get</td><td>82.62</td><td>0.08</td><td>0.03</td></tr><tr><td>Native JS Map 1,000,000 set & get</td><td>278.89</td><td>0.28</td><td>0.02</td></tr><tr><td>Native JS Set 1,000,000 add & has</td><td>237.93</td><td>0.24</td><td>0.02</td></tr><tr><td>1,000,000 ObjKey set & get</td><td>369.62</td><td>0.37</td><td>0.07</td></tr><tr><td>Native JS Map 1,000,000 ObjKey set & get</td><td>332.09</td><td>0.33</td><td>0.10</td></tr><tr><td>Native JS Set 1,000,000 ObjKey add & has</td><td>271.98</td><td>0.27</td><td>0.03</td></tr></table></div>
68
+ </div><div class="json-to-html-collapse clearfix 0">
69
+ <div class='collapsible level0' ><span class='json-to-html-label'>trie</span></div>
70
+ <div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>sample mean (secs)</th><th>sample deviation</th></tr><tr><td>100,000 push</td><td>42.65</td><td>0.04</td><td>8.66e-4</td></tr><tr><td>100,000 getWords</td><td>83.37</td><td>0.08</td><td>0.00</td></tr></table></div>
71
+ </div><div class="json-to-html-collapse clearfix 0">
72
+ <div class='collapsible level0' ><span class='json-to-html-label'>stack</span></div>
73
+ <div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>sample mean (secs)</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>41.84</td><td>0.04</td><td>0.01</td></tr><tr><td>1,000,000 push & pop</td><td>46.56</td><td>0.05</td><td>0.01</td></tr></table></div>
50
74
  </div>
51
75
 
52
76
  </div>
@@ -1,47 +1,64 @@
1
1
  {
2
+ "heap": {
3
+ "benchmarks": [
4
+ {
5
+ "test name": "100,000 add",
6
+ "time taken (ms)": "6.66",
7
+ "sample mean (secs)": "0.01",
8
+ "sample deviation": "1.93e-4"
9
+ },
10
+ {
11
+ "test name": "100,000 add & poll",
12
+ "time taken (ms)": "35.36",
13
+ "sample mean (secs)": "0.04",
14
+ "sample deviation": "0.00"
15
+ }
16
+ ],
17
+ "testName": "heap"
18
+ },
2
19
  "avl-tree": {
3
20
  "benchmarks": [
4
21
  {
5
22
  "test name": "100,000 add randomly",
6
- "time taken (ms)": "526.46",
7
- "sample mean (secs)": "0.53",
8
- "sample deviation": "0.01"
23
+ "time taken (ms)": "548.16",
24
+ "sample mean (secs)": "0.55",
25
+ "sample deviation": "0.02"
9
26
  },
10
27
  {
11
28
  "test name": "100,000 add",
12
- "time taken (ms)": "474.38",
13
- "sample mean (secs)": "0.47",
14
- "sample deviation": "0.00"
29
+ "time taken (ms)": "503.07",
30
+ "sample mean (secs)": "0.50",
31
+ "sample deviation": "0.02"
15
32
  },
16
33
  {
17
34
  "test name": "100,000 get",
18
- "time taken (ms)": "0.72",
19
- "sample mean (secs)": "7.17e-4",
20
- "sample deviation": "3.47e-4"
35
+ "time taken (ms)": "0.62",
36
+ "sample mean (secs)": "6.18e-4",
37
+ "sample deviation": "2.45e-4"
21
38
  },
22
39
  {
23
40
  "test name": "100,000 getNode",
24
- "time taken (ms)": "252.58",
25
- "sample mean (secs)": "0.25",
26
- "sample deviation": "0.01"
41
+ "time taken (ms)": "326.99",
42
+ "sample mean (secs)": "0.33",
43
+ "sample deviation": "0.00"
27
44
  },
28
45
  {
29
46
  "test name": "100,000 iterator",
30
- "time taken (ms)": "24.84",
31
- "sample mean (secs)": "0.02",
47
+ "time taken (ms)": "32.01",
48
+ "sample mean (secs)": "0.03",
32
49
  "sample deviation": "0.00"
33
50
  },
34
51
  {
35
52
  "test name": "100,000 add & delete orderly",
36
- "time taken (ms)": "717.48",
37
- "sample mean (secs)": "0.72",
38
- "sample deviation": "0.02"
53
+ "time taken (ms)": "809.71",
54
+ "sample mean (secs)": "0.81",
55
+ "sample deviation": "0.08"
39
56
  },
40
57
  {
41
58
  "test name": "100,000 add & delete randomly",
42
- "time taken (ms)": "898.45",
43
- "sample mean (secs)": "0.90",
44
- "sample deviation": "0.02"
59
+ "time taken (ms)": "993.95",
60
+ "sample mean (secs)": "0.99",
61
+ "sample deviation": "0.03"
45
62
  }
46
63
  ],
47
64
  "testName": "avl-tree"
@@ -50,59 +67,292 @@
50
67
  "benchmarks": [
51
68
  {
52
69
  "test name": "100,000 add randomly",
53
- "time taken (ms)": "144.49",
54
- "sample mean (secs)": "0.14",
55
- "sample deviation": "0.01"
70
+ "time taken (ms)": "159.87",
71
+ "sample mean (secs)": "0.16",
72
+ "sample deviation": "0.00"
56
73
  },
57
74
  {
58
75
  "test name": "100,000 add",
59
- "time taken (ms)": "190.53",
60
- "sample mean (secs)": "0.19",
61
- "sample deviation": "0.00"
76
+ "time taken (ms)": "218.47",
77
+ "sample mean (secs)": "0.22",
78
+ "sample deviation": "3.58e-4"
62
79
  },
63
80
  {
64
81
  "test name": "100,000 get",
65
- "time taken (ms)": "0.91",
66
- "sample mean (secs)": "9.14e-4",
67
- "sample deviation": "2.11e-4"
82
+ "time taken (ms)": "1.12",
83
+ "sample mean (secs)": "0.00",
84
+ "sample deviation": "1.82e-4"
68
85
  },
69
86
  {
70
87
  "test name": "100,000 getNode",
71
- "time taken (ms)": "323.66",
72
- "sample mean (secs)": "0.32",
88
+ "time taken (ms)": "511.83",
89
+ "sample mean (secs)": "0.51",
73
90
  "sample deviation": "0.00"
74
91
  },
75
92
  {
76
93
  "test name": "100,000 node mode add randomly",
77
- "time taken (ms)": "139.71",
78
- "sample mean (secs)": "0.14",
94
+ "time taken (ms)": "156.83",
95
+ "sample mean (secs)": "0.16",
79
96
  "sample deviation": "0.00"
80
97
  },
81
98
  {
82
99
  "test name": "100,000 node mode get",
83
- "time taken (ms)": "322.39",
84
- "sample mean (secs)": "0.32",
85
- "sample deviation": "7.58e-4"
100
+ "time taken (ms)": "509.76",
101
+ "sample mean (secs)": "0.51",
102
+ "sample deviation": "0.00"
86
103
  },
87
104
  {
88
105
  "test name": "100,000 iterator",
89
- "time taken (ms)": "27.07",
106
+ "time taken (ms)": "32.75",
90
107
  "sample mean (secs)": "0.03",
91
108
  "sample deviation": "0.00"
92
109
  },
93
110
  {
94
111
  "test name": "100,000 add & delete orderly",
95
- "time taken (ms)": "349.17",
96
- "sample mean (secs)": "0.35",
112
+ "time taken (ms)": "460.34",
113
+ "sample mean (secs)": "0.46",
97
114
  "sample deviation": "0.00"
98
115
  },
99
116
  {
100
117
  "test name": "100,000 add & delete randomly",
101
- "time taken (ms)": "482.61",
102
- "sample mean (secs)": "0.48",
103
- "sample deviation": "0.01"
118
+ "time taken (ms)": "679.75",
119
+ "sample mean (secs)": "0.68",
120
+ "sample deviation": "0.04"
104
121
  }
105
122
  ],
106
123
  "testName": "red-black-tree"
124
+ },
125
+ "doubly-linked-list": {
126
+ "benchmarks": [
127
+ {
128
+ "test name": "1,000,000 push",
129
+ "time taken (ms)": "182.03",
130
+ "sample mean (secs)": "0.18",
131
+ "sample deviation": "0.02"
132
+ },
133
+ {
134
+ "test name": "1,000,000 unshift",
135
+ "time taken (ms)": "185.94",
136
+ "sample mean (secs)": "0.19",
137
+ "sample deviation": "0.03"
138
+ },
139
+ {
140
+ "test name": "1,000,000 unshift & shift",
141
+ "time taken (ms)": "159.02",
142
+ "sample mean (secs)": "0.16",
143
+ "sample deviation": "0.03"
144
+ },
145
+ {
146
+ "test name": "1,000,000 addBefore",
147
+ "time taken (ms)": "252.73",
148
+ "sample mean (secs)": "0.25",
149
+ "sample deviation": "0.03"
150
+ }
151
+ ],
152
+ "testName": "doubly-linked-list"
153
+ },
154
+ "directed-graph": {
155
+ "benchmarks": [
156
+ {
157
+ "test name": "1,000 addVertex",
158
+ "time taken (ms)": "0.10",
159
+ "sample mean (secs)": "9.56e-5",
160
+ "sample deviation": "9.71e-7"
161
+ },
162
+ {
163
+ "test name": "1,000 addEdge",
164
+ "time taken (ms)": "5.97",
165
+ "sample mean (secs)": "0.01",
166
+ "sample deviation": "1.99e-4"
167
+ },
168
+ {
169
+ "test name": "1,000 getVertex",
170
+ "time taken (ms)": "0.10",
171
+ "sample mean (secs)": "9.71e-5",
172
+ "sample deviation": "1.17e-6"
173
+ },
174
+ {
175
+ "test name": "1,000 getEdge",
176
+ "time taken (ms)": "23.25",
177
+ "sample mean (secs)": "0.02",
178
+ "sample deviation": "0.00"
179
+ },
180
+ {
181
+ "test name": "tarjan",
182
+ "time taken (ms)": "192.40",
183
+ "sample mean (secs)": "0.19",
184
+ "sample deviation": "0.00"
185
+ },
186
+ {
187
+ "test name": "topologicalSort",
188
+ "time taken (ms)": "151.03",
189
+ "sample mean (secs)": "0.15",
190
+ "sample deviation": "0.01"
191
+ }
192
+ ],
193
+ "testName": "directed-graph"
194
+ },
195
+ "queue": {
196
+ "benchmarks": [
197
+ {
198
+ "test name": "1,000,000 push",
199
+ "time taken (ms)": "53.79",
200
+ "sample mean (secs)": "0.05",
201
+ "sample deviation": "0.02"
202
+ },
203
+ {
204
+ "test name": "100,000 push & shift",
205
+ "time taken (ms)": "5.49",
206
+ "sample mean (secs)": "0.01",
207
+ "sample deviation": "0.00"
208
+ },
209
+ {
210
+ "test name": "Native JS Array 100,000 push & shift",
211
+ "time taken (ms)": "2358.01",
212
+ "sample mean (secs)": "2.36",
213
+ "sample deviation": "0.32"
214
+ }
215
+ ],
216
+ "testName": "queue"
217
+ },
218
+ "deque": {
219
+ "benchmarks": [
220
+ {
221
+ "test name": "1,000,000 push",
222
+ "time taken (ms)": "23.74",
223
+ "sample mean (secs)": "0.02",
224
+ "sample deviation": "0.01"
225
+ },
226
+ {
227
+ "test name": "1,000,000 push & pop",
228
+ "time taken (ms)": "25.37",
229
+ "sample mean (secs)": "0.03",
230
+ "sample deviation": "0.01"
231
+ },
232
+ {
233
+ "test name": "1,000,000 push & shift",
234
+ "time taken (ms)": "27.61",
235
+ "sample mean (secs)": "0.03",
236
+ "sample deviation": "0.01"
237
+ },
238
+ {
239
+ "test name": "100,000 push & shift",
240
+ "time taken (ms)": "2.77",
241
+ "sample mean (secs)": "0.00",
242
+ "sample deviation": "0.00"
243
+ },
244
+ {
245
+ "test name": "Native JS Array 100,000 push & shift",
246
+ "time taken (ms)": "2430.40",
247
+ "sample mean (secs)": "2.43",
248
+ "sample deviation": "0.31"
249
+ },
250
+ {
251
+ "test name": "100,000 unshift & shift",
252
+ "time taken (ms)": "2.46",
253
+ "sample mean (secs)": "0.00",
254
+ "sample deviation": "8.81e-4"
255
+ },
256
+ {
257
+ "test name": "Native JS Array 100,000 unshift & shift",
258
+ "time taken (ms)": "4239.82",
259
+ "sample mean (secs)": "4.24",
260
+ "sample deviation": "0.37"
261
+ }
262
+ ],
263
+ "testName": "deque"
264
+ },
265
+ "hash-map": {
266
+ "benchmarks": [
267
+ {
268
+ "test name": "1,000,000 set",
269
+ "time taken (ms)": "96.79",
270
+ "sample mean (secs)": "0.10",
271
+ "sample deviation": "0.05"
272
+ },
273
+ {
274
+ "test name": "Native JS Map 1,000,000 set",
275
+ "time taken (ms)": "230.38",
276
+ "sample mean (secs)": "0.23",
277
+ "sample deviation": "0.05"
278
+ },
279
+ {
280
+ "test name": "Native JS Set 1,000,000 add",
281
+ "time taken (ms)": "170.58",
282
+ "sample mean (secs)": "0.17",
283
+ "sample deviation": "0.01"
284
+ },
285
+ {
286
+ "test name": "1,000,000 set & get",
287
+ "time taken (ms)": "82.62",
288
+ "sample mean (secs)": "0.08",
289
+ "sample deviation": "0.03"
290
+ },
291
+ {
292
+ "test name": "Native JS Map 1,000,000 set & get",
293
+ "time taken (ms)": "278.89",
294
+ "sample mean (secs)": "0.28",
295
+ "sample deviation": "0.02"
296
+ },
297
+ {
298
+ "test name": "Native JS Set 1,000,000 add & has",
299
+ "time taken (ms)": "237.93",
300
+ "sample mean (secs)": "0.24",
301
+ "sample deviation": "0.02"
302
+ },
303
+ {
304
+ "test name": "1,000,000 ObjKey set & get",
305
+ "time taken (ms)": "369.62",
306
+ "sample mean (secs)": "0.37",
307
+ "sample deviation": "0.07"
308
+ },
309
+ {
310
+ "test name": "Native JS Map 1,000,000 ObjKey set & get",
311
+ "time taken (ms)": "332.09",
312
+ "sample mean (secs)": "0.33",
313
+ "sample deviation": "0.10"
314
+ },
315
+ {
316
+ "test name": "Native JS Set 1,000,000 ObjKey add & has",
317
+ "time taken (ms)": "271.98",
318
+ "sample mean (secs)": "0.27",
319
+ "sample deviation": "0.03"
320
+ }
321
+ ],
322
+ "testName": "hash-map"
323
+ },
324
+ "trie": {
325
+ "benchmarks": [
326
+ {
327
+ "test name": "100,000 push",
328
+ "time taken (ms)": "42.65",
329
+ "sample mean (secs)": "0.04",
330
+ "sample deviation": "8.66e-4"
331
+ },
332
+ {
333
+ "test name": "100,000 getWords",
334
+ "time taken (ms)": "83.37",
335
+ "sample mean (secs)": "0.08",
336
+ "sample deviation": "0.00"
337
+ }
338
+ ],
339
+ "testName": "trie"
340
+ },
341
+ "stack": {
342
+ "benchmarks": [
343
+ {
344
+ "test name": "1,000,000 push",
345
+ "time taken (ms)": "41.84",
346
+ "sample mean (secs)": "0.04",
347
+ "sample deviation": "0.01"
348
+ },
349
+ {
350
+ "test name": "1,000,000 push & pop",
351
+ "time taken (ms)": "46.56",
352
+ "sample mean (secs)": "0.05",
353
+ "sample deviation": "0.01"
354
+ }
355
+ ],
356
+ "testName": "stack"
107
357
  }
108
358
  }
@@ -1,20 +1,12 @@
1
1
  import { ElementCallback, IterableElementBaseOptions, ReduceElementCallback } from '../../types';
2
- export declare abstract class IterableElementBase<E, R, C> {
2
+ export declare abstract class IterableElementBase<E, R> {
3
3
  /**
4
4
  * The protected constructor initializes the options for the IterableElementBase class, including the
5
5
  * toElementFn function.
6
6
  * @param [options] - An optional object that contains the following properties:
7
7
  */
8
8
  protected constructor(options?: IterableElementBaseOptions<E, R>);
9
- abstract get size(): number;
10
9
  protected _toElementFn?: (rawElement: R) => E;
11
- /**
12
- * The function returns the _toElementFn property, which is a function that converts a raw element to
13
- * a specific type.
14
- * @returns The function `get toElementFn()` is returning either a function that takes a raw element
15
- * `rawElement` of type `R` and returns an element `E`, or `undefined` if no function is assigned to
16
- * `_toElementFn`.
17
- */
18
10
  get toElementFn(): ((rawElement: R) => E) | undefined;
19
11
  /**
20
12
  * Time Complexity: O(n)
@@ -47,7 +39,7 @@ export declare abstract class IterableElementBase<E, R, C> {
47
39
  * @returns The `every` method is returning a boolean value. It returns `true` if every element in
48
40
  * the array satisfies the provided predicate function, and `false` otherwise.
49
41
  */
50
- every(predicate: ElementCallback<E, R, boolean, C>, thisArg?: any): boolean;
42
+ every(predicate: ElementCallback<E, R, boolean>, thisArg?: any): boolean;
51
43
  /**
52
44
  * Time Complexity: O(n)
53
45
  * Space Complexity: O(1)
@@ -62,7 +54,7 @@ export declare abstract class IterableElementBase<E, R, C> {
62
54
  * @returns a boolean value. It returns true if the predicate function returns true for any element
63
55
  * in the collection, and false otherwise.
64
56
  */
65
- some(predicate: ElementCallback<E, R, boolean, C>, thisArg?: any): boolean;
57
+ some(predicate: ElementCallback<E, R, boolean>, thisArg?: any): boolean;
66
58
  /**
67
59
  * Time Complexity: O(n)
68
60
  * Space Complexity: O(1)
@@ -76,24 +68,9 @@ export declare abstract class IterableElementBase<E, R, C> {
76
68
  * to be used as `this` when executing the `callbackfn` function. If `thisArg` is provided, it will
77
69
  * be passed as the `this` value to the `callbackfn` function. If `thisArg
78
70
  */
79
- forEach(callbackfn: ElementCallback<E, R, void, C>, thisArg?: any): void;
80
- /**
81
- * Time Complexity: O(n)
82
- * Space Complexity: O(1)
83
- *
84
- * The `find` function iterates over the elements of an array-like object and returns the first
85
- * element that satisfies the provided callback function.
86
- * @param callbackfn - The callbackfn parameter is a function that will be called for each element in
87
- * the array. It takes three arguments: the current element being processed, the index of the current
88
- * element, and the array itself. The function should return a boolean value indicating whether the
89
- * current element matches the desired condition.
90
- * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
91
- * to be used as `this` when executing the `callbackfn` function. If `thisArg` is provided, it will
92
- * be passed as the `this` value to the `callbackfn` function. If `thisArg
93
- * @returns The `find` method returns the first element in the array that satisfies the provided
94
- * callback function. If no element satisfies the callback function, `undefined` is returned.
95
- */
96
- find(callbackfn: ElementCallback<E, R, boolean, C>, thisArg?: any): E | undefined;
71
+ forEach(callbackfn: ElementCallback<E, R, void>, thisArg?: any): void;
72
+ find<S extends E>(predicate: ElementCallback<E, R, S>, thisArg?: any): S | undefined;
73
+ find(predicate: ElementCallback<E, R, unknown>, thisArg?: any): E | undefined;
97
74
  /**
98
75
  * Time Complexity: O(n)
99
76
  * Space Complexity: O(1)
@@ -105,20 +82,17 @@ export declare abstract class IterableElementBase<E, R, C> {
105
82
  * otherwise.
106
83
  */
107
84
  has(element: E): boolean;
85
+ reduce(callbackfn: ReduceElementCallback<E, R>): E;
86
+ reduce(callbackfn: ReduceElementCallback<E, R>, initialValue: E): E;
87
+ reduce<U>(callbackfn: ReduceElementCallback<E, R, U>, initialValue: U): U;
108
88
  /**
109
89
  * Time Complexity: O(n)
110
- * Space Complexity: O(1)
90
+ * Space Complexity: O(n)
111
91
  *
112
- * The `reduce` function iterates over the elements of an array-like object and applies a callback
113
- * function to reduce them into a single value.
114
- * @param callbackfn - The callbackfn parameter is a function that will be called for each element in
115
- * the array. It takes four arguments:
116
- * @param {U} initialValue - The initialValue parameter is the initial value of the accumulator. It
117
- * is the value that the accumulator starts with before the reduction operation begins.
118
- * @returns The `reduce` method is returning the final value of the accumulator after iterating over
119
- * all the elements in the array and applying the callback function to each element.
92
+ * The `toArray` function converts a linked list into an array.
93
+ * @returns The `toArray()` method is returning an array of type `E[]`.
120
94
  */
121
- reduce<U>(callbackfn: ReduceElementCallback<E, R, U, C>, initialValue: U): U;
95
+ toArray(): E[];
122
96
  /**
123
97
  * Time Complexity: O(n)
124
98
  * Space Complexity: O(n)
@@ -135,7 +109,7 @@ export declare abstract class IterableElementBase<E, R, C> {
135
109
  print(): void;
136
110
  abstract isEmpty(): boolean;
137
111
  abstract clear(): void;
138
- abstract clone(): C;
112
+ abstract clone(): IterableElementBase<E, R>;
139
113
  abstract map(...args: any[]): any;
140
114
  abstract filter(...args: any[]): any;
141
115
  protected abstract _getIterator(...args: any[]): IterableIterator<E>;
@@ -16,13 +16,6 @@ class IterableElementBase {
16
16
  throw new TypeError('toElementFn must be a function type');
17
17
  }
18
18
  }
19
- /**
20
- * The function returns the _toElementFn property, which is a function that converts a raw element to
21
- * a specific type.
22
- * @returns The function `get toElementFn()` is returning either a function that takes a raw element
23
- * `rawElement` of type `R` and returns an element `E`, or `undefined` if no function is assigned to
24
- * `_toElementFn`.
25
- */
26
19
  get toElementFn() {
27
20
  return this._toElementFn;
28
21
  }
@@ -120,7 +113,7 @@ class IterableElementBase {
120
113
  *
121
114
  * The `find` function iterates over the elements of an array-like object and returns the first
122
115
  * element that satisfies the provided callback function.
123
- * @param callbackfn - The callbackfn parameter is a function that will be called for each element in
116
+ * @param predicate - The predicate parameter is a function that will be called for each element in
124
117
  * the array. It takes three arguments: the current element being processed, the index of the current
125
118
  * element, and the array itself. The function should return a boolean value indicating whether the
126
119
  * current element matches the desired condition.
@@ -130,10 +123,10 @@ class IterableElementBase {
130
123
  * @returns The `find` method returns the first element in the array that satisfies the provided
131
124
  * callback function. If no element satisfies the callback function, `undefined` is returned.
132
125
  */
133
- find(callbackfn, thisArg) {
126
+ find(predicate, thisArg) {
134
127
  let index = 0;
135
128
  for (const item of this) {
136
- if (callbackfn.call(thisArg, item, index++, this))
129
+ if (predicate.call(thisArg, item, index++, this))
137
130
  return item;
138
131
  }
139
132
  return;
@@ -169,13 +162,23 @@ class IterableElementBase {
169
162
  * all the elements in the array and applying the callback function to each element.
170
163
  */
171
164
  reduce(callbackfn, initialValue) {
172
- let accumulator = initialValue;
165
+ let accumulator = initialValue !== null && initialValue !== void 0 ? initialValue : 0;
173
166
  let index = 0;
174
167
  for (const item of this) {
175
168
  accumulator = callbackfn(accumulator, item, index++, this);
176
169
  }
177
170
  return accumulator;
178
171
  }
172
+ /**
173
+ * Time Complexity: O(n)
174
+ * Space Complexity: O(n)
175
+ *
176
+ * The `toArray` function converts a linked list into an array.
177
+ * @returns The `toArray()` method is returning an array of type `E[]`.
178
+ */
179
+ toArray() {
180
+ return [...this];
181
+ }
179
182
  /**
180
183
  * Time Complexity: O(n)
181
184
  * Space Complexity: O(n)
@@ -1 +1 @@
1
- {"version":3,"file":"iterable-element-base.js","sourceRoot":"","sources":["../../../../src/data-structures/base/iterable-element-base.ts"],"names":[],"mappings":";;;AAEA,MAAsB,mBAAmB;IACvC;;;;OAIG;IACH,YAAsB,OAA0C;QAC9D,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;YAChC,IAAI,OAAO,WAAW,KAAK,UAAU;gBAAE,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;iBAClE,IAAI,WAAW;gBAAE,MAAM,IAAI,SAAS,CAAC,qCAAqC,CAAC,CAAC;QACnF,CAAC;IACH,CAAC;IAMD;;;;;;OAMG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;;;;;;;OAQG;IACH,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAW;QAC/B,KAAK,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACH,CAAC,MAAM;QACL,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC;QACb,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,SAA4C,EAAE,OAAa;QAC/D,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;gBAClD,OAAO,KA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AC;QAC/B,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,IAAS,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACN,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACH,KAAK;QACH,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/B,CAAC;CAaF;AAzND,kDAyNC"}
1
+ {"version":3,"file":"iterable-element-base.js","sourceRoot":"","sources":["../../../../src/data-structures/base/iterable-element-base.ts"],"names":[],"mappings":";;;AAEA,MAAsB,mBAAmB;IACvC;;;;OAIG;IACH,YAAsB,OAA0C;QAC9D,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;YAChC,IAAI,OAAO,WAAW,KAAK,UAAU;gBAAE,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;iBAClE,IAAI,WAAW;gBAAE,MAAM,IAAI,SAAS,CAAC,qCAAqC,CAAC,CAAC;QACnF,CAAC;IACH,CAAC;IAID,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;;;;;;;OAQG;IACH,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAW;QAC/B,KAAK,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACH,CAAC,MAAM;QACL,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC;QACb,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,S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