fix: Removed unused enums. style: Beautified text color output of the performance report generator console.

This commit is contained in:
Revone 2023-11-14 21:41:20 +08:00
parent cfe97b3adc
commit d71a1eb2bc
8 changed files with 164 additions and 57 deletions

View file

@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file.
- [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
- [`auto-changelog`](https://github.com/CookPete/auto-changelog)
## [v1.43.3](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming)
## [v1.44.0](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming)
### Changes

View file

@ -735,49 +735,49 @@ optimal approach to data structure design.
[//]: # (No deletion!!! Start of Replace Section)
<div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>avl-tree</span></div>
<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>35.38</td><td>28.26</td><td>0.00</td></tr><tr><td>10,000 add & delete randomly</td><td>80.65</td><td>12.40</td><td>0.01</td></tr><tr><td>10,000 addMany</td><td>46.45</td><td>21.53</td><td>9.97e-4</td></tr><tr><td>10,000 get</td><td>31.59</td><td>31.66</td><td>0.00</td></tr></table></div>
<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>33.23</td><td>30.09</td><td>0.00</td></tr><tr><td>10,000 add & delete randomly</td><td>71.07</td><td>14.07</td><td>0.00</td></tr><tr><td>10,000 addMany</td><td>40.89</td><td>24.45</td><td>4.42e-4</td></tr><tr><td>10,000 get</td><td>28.00</td><td>35.72</td><td>3.66e-4</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>binary-tree</span></div>
<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>13.01</td><td>76.84</td><td>7.71e-4</td></tr><tr><td>1,000 add & delete randomly</td><td>16.82</td><td>59.46</td><td>0.00</td></tr><tr><td>1,000 addMany</td><td>10.46</td><td>95.62</td><td>2.13e-4</td></tr><tr><td>1,000 get</td><td>18.44</td><td>54.22</td><td>2.49e-4</td></tr><tr><td>1,000 dfs</td><td>163.31</td><td>6.12</td><td>0.01</td></tr><tr><td>1,000 bfs</td><td>58.07</td><td>17.22</td><td>0.00</td></tr><tr><td>1,000 morris</td><td>273.11</td><td>3.66</td><td>0.00</td></tr></table></div>
<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.40</td><td>80.64</td><td>1.37e-4</td></tr><tr><td>1,000 add & delete randomly</td><td>16.13</td><td>61.98</td><td>8.55e-4</td></tr><tr><td>1,000 addMany</td><td>10.34</td><td>96.68</td><td>1.34e-4</td></tr><tr><td>1,000 get</td><td>18.65</td><td>53.63</td><td>8.17e-4</td></tr><tr><td>1,000 dfs</td><td>155.93</td><td>6.41</td><td>6.00e-4</td></tr><tr><td>1,000 bfs</td><td>56.08</td><td>17.83</td><td>2.98e-4</td></tr><tr><td>1,000 morris</td><td>257.05</td><td>3.89</td><td>0.00</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>bst</span></div>
<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>33.44</td><td>29.91</td><td>5.09e-4</td></tr><tr><td>10,000 add & delete randomly</td><td>76.03</td><td>13.15</td><td>0.00</td></tr><tr><td>10,000 addMany</td><td>32.26</td><td>31.00</td><td>0.00</td></tr><tr><td>10,000 get</td><td>32.75</td><td>30.53</td><td>0.01</td></tr></table></div>
<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>28.53</td><td>35.05</td><td>9.51e-4</td></tr><tr><td>10,000 add & delete randomly</td><td>66.89</td><td>14.95</td><td>9.60e-4</td></tr><tr><td>10,000 addMany</td><td>30.94</td><td>32.32</td><td>0.01</td></tr><tr><td>10,000 get</td><td>28.18</td><td>35.48</td><td>4.43e-4</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>rb-tree</span></div>
<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>99.27</td><td>10.07</td><td>0.01</td></tr><tr><td>100,000 add & delete randomly</td><td>233.22</td><td>4.29</td><td>0.01</td></tr><tr><td>100,000 getNode</td><td>148.41</td><td>6.74</td><td>0.00</td></tr></table></div>
<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>87.93</td><td>11.37</td><td>0.00</td></tr><tr><td>100,000 add & delete randomly</td><td>218.68</td><td>4.57</td><td>0.01</td></tr><tr><td>100,000 getNode</td><td>99.74</td><td>10.03</td><td>7.04e-4</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>directed-graph</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000 addVertex</td><td>0.11</td><td>9381.52</td><td>3.21e-6</td></tr><tr><td>1,000 addEdge</td><td>6.36</td><td>157.14</td><td>7.19e-4</td></tr><tr><td>1,000 getVertex</td><td>0.05</td><td>2.09e+4</td><td>2.72e-6</td></tr><tr><td>1,000 getEdge</td><td>24.66</td><td>40.55</td><td>0.00</td></tr><tr><td>tarjan</td><td>219.65</td><td>4.55</td><td>0.01</td></tr><tr><td>tarjan all</td><td>239.68</td><td>4.17</td><td>0.04</td></tr><tr><td>topologicalSort</td><td>216.14</td><td>4.63</td><td>0.07</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000 addVertex</td><td>0.11</td><td>9305.58</td><td>1.07e-5</td></tr><tr><td>1,000 addEdge</td><td>7.66</td><td>130.50</td><td>0.00</td></tr><tr><td>1,000 getVertex</td><td>0.05</td><td>2.03e+4</td><td>4.70e-6</td></tr><tr><td>1,000 getEdge</td><td>27.22</td><td>36.74</td><td>0.01</td></tr><tr><td>tarjan</td><td>186.49</td><td>5.36</td><td>0.01</td></tr><tr><td>tarjan all</td><td>190.28</td><td>5.26</td><td>0.00</td></tr><tr><td>topologicalSort</td><td>157.12</td><td>6.36</td><td>0.00</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>hash-map</span></div>
<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 set</td><td>19.50</td><td>51.27</td><td>0.01</td></tr><tr><td>10,000 set & get</td><td>38.20</td><td>26.18</td><td>0.01</td></tr></table></div>
<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 set</td><td>16.07</td><td>62.24</td><td>3.45e-4</td></tr><tr><td>10,000 set & get</td><td>34.83</td><td>28.71</td><td>5.83e-4</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>heap</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 add & pop</td><td>4.86</td><td>205.69</td><td>7.04e-4</td></tr><tr><td>10,000 fib add & pop</td><td>386.50</td><td>2.59</td><td>0.03</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 add & pop</td><td>4.63</td><td>215.97</td><td>4.24e-5</td></tr><tr><td>10,000 fib add & pop</td><td>380.19</td><td>2.63</td><td>0.07</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>doubly-linked-list</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 unshift</td><td>243.46</td><td>4.11</td><td>0.05</td></tr><tr><td>1,000,000 unshift & shift</td><td>178.49</td><td>5.60</td><td>0.02</td></tr><tr><td>1,000,000 insertBefore</td><td>326.38</td><td>3.06</td><td>0.07</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 unshift</td><td>218.86</td><td>4.57</td><td>0.07</td></tr><tr><td>1,000,000 unshift & shift</td><td>171.50</td><td>5.83</td><td>0.02</td></tr><tr><td>1,000,000 insertBefore</td><td>328.27</td><td>3.05</td><td>0.06</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>singly-linked-list</span></div>
<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>232.85</td><td>4.29</td><td>0.01</td></tr><tr><td>10,000 insertBefore</td><td>255.90</td><td>3.91</td><td>0.01</td></tr></table></div>
<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>224.78</td><td>4.45</td><td>0.01</td></tr><tr><td>10,000 insertBefore</td><td>253.69</td><td>3.94</td><td>0.02</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>max-priority-queue</span></div>
<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>11.88</td><td>84.15</td><td>0.00</td></tr></table></div>
<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>11.98</td><td>83.50</td><td>0.00</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>priority-queue</span></div>
<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>12.60</td><td>79.35</td><td>1.40e-4</td></tr></table></div>
<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>12.65</td><td>79.04</td><td>8.45e-4</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>deque</span></div>
<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>226.32</td><td>4.42</td><td>0.03</td></tr><tr><td>1,000,000 shift</td><td>26.09</td><td>38.33</td><td>0.00</td></tr></table></div>
<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>231.26</td><td>4.32</td><td>0.04</td></tr><tr><td>1,000,000 shift</td><td>28.05</td><td>35.65</td><td>0.01</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>queue</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>45.45</td><td>22.00</td><td>0.01</td></tr><tr><td>1,000,000 push & shift</td><td>82.87</td><td>12.07</td><td>0.00</td></tr></table></div>
<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>48.01</td><td>20.83</td><td>0.02</td></tr><tr><td>1,000,000 push & shift</td><td>83.34</td><td>12.00</td><td>0.00</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>stack</span></div>
<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>43.95</td><td>22.75</td><td>0.01</td></tr><tr><td>1,000,000 push & pop</td><td>50.91</td><td>19.64</td><td>0.00</td></tr></table></div>
<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>43.24</td><td>23.13</td><td>0.01</td></tr><tr><td>1,000,000 push & pop</td><td>57.96</td><td>17.25</td><td>0.02</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>trie</span></div>
<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>50.20</td><td>19.92</td><td>0.00</td></tr><tr><td>100,000 getWords</td><td>110.08</td><td>9.08</td><td>0.01</td></tr></table></div>
<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>58.12</td><td>17.21</td><td>0.02</td></tr><tr><td>100,000 getWords</td><td>144.39</td><td>6.93</td><td>0.13</td></tr></table></div>
</div>
[//]: # (No deletion!!! End of Replace Section)

51
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "data-structure-typed",
"version": "1.43.3",
"version": "1.44.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "data-structure-typed",
"version": "1.43.3",
"version": "1.44.0",
"license": "MIT",
"devDependencies": {
"@swc/core": "^1.3.96",
@ -17,10 +17,11 @@
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"auto-changelog": "^2.4.0",
"avl-tree-typed": "^1.42.5",
"avl-tree-typed": "^1.44.0",
"benchmark": "^2.1.4",
"binary-tree-typed": "^1.42.5",
"bst-typed": "^1.42.5",
"binary-tree-typed": "^1.44.0",
"bst-typed": "^1.44.0",
"data-structure-typed": "^1.44.0",
"dependency-cruiser": "^14.1.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
@ -28,7 +29,7 @@
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.28.1",
"fast-glob": "^3.3.1",
"heap-typed": "^1.42.5",
"heap-typed": "^1.44.0",
"istanbul-badges-readme": "^1.8.5",
"jest": "^29.7.0",
"js-sdsl": "^4.4.2",
@ -3001,12 +3002,12 @@
}
},
"node_modules/avl-tree-typed": {
"version": "1.43.1",
"resolved": "https://registry.npmjs.org/avl-tree-typed/-/avl-tree-typed-1.43.1.tgz",
"integrity": "sha512-XeCTZGn4Wo5HjO1gwqtZ80Q3nBn2I2PB7WVemeyhHAGzvXCzjDOvtzFzHUHw/VebIQEXYacIzPqyjCZwSRH/aQ==",
"version": "1.44.0",
"resolved": "https://registry.npmjs.org/avl-tree-typed/-/avl-tree-typed-1.44.0.tgz",
"integrity": "sha512-XaKEv9Y6IR7vCy2n5NPOczPnuPPny801MGQIN9supoz1yku7wfN99JBtZI2VN+F60eNo302pTEelgDV8AYiV1Q==",
"dev": true,
"dependencies": {
"data-structure-typed": "^1.43.1"
"data-structure-typed": "^1.44.0"
}
},
"node_modules/babel-jest": {
@ -3200,12 +3201,12 @@
}
},
"node_modules/binary-tree-typed": {
"version": "1.43.1",
"resolved": "https://registry.npmjs.org/binary-tree-typed/-/binary-tree-typed-1.43.1.tgz",
"integrity": "sha512-3j3QX1vuk0WNfYLgC+yeYdAn5vRT/kO/8+OS94B924PCVPRNddOyO3rSVl0aJq/N0ihUR8z0brQnR/HC9Mo09A==",
"version": "1.44.0",
"resolved": "https://registry.npmjs.org/binary-tree-typed/-/binary-tree-typed-1.44.0.tgz",
"integrity": "sha512-f+g6X8prsdlzx++ac44zER0QtrdnL6I7hIgHBR1JuLOve4Hcrb5fkNAXtQwA4vOtmghtGYcGl4IOlhtyRMuF/w==",
"dev": true,
"dependencies": {
"data-structure-typed": "^1.43.1"
"data-structure-typed": "^1.44.0"
}
},
"node_modules/brace-expansion": {
@ -3284,12 +3285,12 @@
}
},
"node_modules/bst-typed": {
"version": "1.43.1",
"resolved": "https://registry.npmjs.org/bst-typed/-/bst-typed-1.43.1.tgz",
"integrity": "sha512-IeSQ8a6z1A8C0csPb4pqQOQNgQi1NnH/GfLL4Nx2aSA1NvF25nXK+f61Vz+t3a4pzcgmBjI+wYMZNYmSLrZ3NQ==",
"version": "1.44.0",
"resolved": "https://registry.npmjs.org/bst-typed/-/bst-typed-1.44.0.tgz",
"integrity": "sha512-PQ75B1aWXE5fuenMZ3lAIVV+Ek/7OJp2kJty0sGlVvtR0MENIz8MnT0tNt+3XzHjbhml0gcvh5KNaqCKyQIdSQ==",
"dev": true,
"dependencies": {
"data-structure-typed": "^1.43.1"
"data-structure-typed": "^1.44.0"
}
},
"node_modules/buffer-from": {
@ -3692,9 +3693,9 @@
}
},
"node_modules/data-structure-typed": {
"version": "1.43.1",
"resolved": "https://registry.npmjs.org/data-structure-typed/-/data-structure-typed-1.43.1.tgz",
"integrity": "sha512-STWriSmxUv78EYJiBtyPPDzEX1xfSzOvZFamUorHxEoWw1m5Sl0TESsC2biNIJ/GXZWhhJG7Tef6hseXWZ6GVw==",
"version": "1.44.0",
"resolved": "https://registry.npmjs.org/data-structure-typed/-/data-structure-typed-1.44.0.tgz",
"integrity": "sha512-mS/JWpl/evwqnWtIRmGqvwHR6NEbzuAp3AkK8keq1J45vctxryX8YKTS56u5JHE2MNTZc+5Tt+H5ltmLfz18SQ==",
"dev": true
},
"node_modules/debug": {
@ -5059,12 +5060,12 @@
}
},
"node_modules/heap-typed": {
"version": "1.43.1",
"resolved": "https://registry.npmjs.org/heap-typed/-/heap-typed-1.43.1.tgz",
"integrity": "sha512-nKRcoir8MJF4qJFp6na1DZNWBl2wi5f5BM/qlrvkMina9Dxbphwrl7pPtlcJ3ohdl3lXTjZNrCU7dWntH4djaA==",
"version": "1.44.0",
"resolved": "https://registry.npmjs.org/heap-typed/-/heap-typed-1.44.0.tgz",
"integrity": "sha512-QKmfpcZV3Fc0X5uopTejcaElLvEZe/D7ZdCdeAQdQnJpLGUD+gsVWNJeHKl4ek2P+1w/PNkbOgv6RJ4Cr6MM6w==",
"dev": true,
"dependencies": {
"data-structure-typed": "^1.43.1"
"data-structure-typed": "^1.44.0"
}
},
"node_modules/html-escaper": {

View file

@ -1,6 +1,6 @@
{
"name": "data-structure-typed",
"version": "1.43.3",
"version": "1.44.1",
"description": "Data Structures of Javascript & TypeScript. Binary Tree, BST, Graph, Heap, Priority Queue, Linked List, Queue, Deque, Stack, AVL Tree, Tree Multiset, Trie, Directed Graph, Undirected Graph, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue.",
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
@ -20,6 +20,7 @@
"build:umd": "tsup",
"build:docs": "typedoc --out docs ./src",
"test:unit": "jest --runInBand",
"test": "npm run test:unit",
"test:integration": "npm run update:subs && jest --config jest.integration.config.js",
"test:perf": "ts-node test/performance/reportor.ts",
"check": "tsc --noEmit",
@ -32,7 +33,7 @@
"format:test": "prettier --write 'test/**/*.{js,ts}'",
"format": "npm run format:src && npm run format:test",
"ci": "env && git fetch --tags && npm run check && npm run lint && npm run build && npm run test:unit && npm run changelog",
"update:subs": "npm i avl-tree-typed binary-tree-typed bst-typed heap-typed --save-dev",
"update:subs": "npm i avl-tree-typed binary-tree-typed bst-typed heap-typed data-structure-typed --save-dev",
"install:all-subs": "npm i avl-tree-typed binary-tree-typed bst-typed deque-typed directed-graph-typed doubly-linked-list-typed graph-typed heap-typed linked-list-typed max-heap-typed max-priority-queue-typed min-heap-typed min-priority-queue-typed priority-queue-typed singly-linked-list-typed stack-typed tree-multimap-typed trie-typed undirected-graph-typed queue-typed --save-dev",
"changelog": "auto-changelog",
"coverage:badge": "istanbul-badges-readme",
@ -63,10 +64,11 @@
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"auto-changelog": "^2.4.0",
"avl-tree-typed": "^1.42.5",
"avl-tree-typed": "^1.44.0",
"benchmark": "^2.1.4",
"binary-tree-typed": "^1.42.5",
"bst-typed": "^1.42.5",
"binary-tree-typed": "^1.44.0",
"bst-typed": "^1.44.0",
"data-structure-typed": "^1.44.0",
"dependency-cruiser": "^14.1.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
@ -74,7 +76,7 @@
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.28.1",
"fast-glob": "^3.3.1",
"heap-typed": "^1.42.5",
"heap-typed": "^1.44.0",
"istanbul-badges-readme": "^1.8.5",
"jest": "^29.7.0",
"js-sdsl": "^4.4.2",

View file

@ -1,8 +1,2 @@
// 0 means unknown, 1 means visiting, 2 means visited;
export type TopologicalStatus = 0 | 1 | 2;
export enum TopologicalProperty {
VAL = 'VAL',
NODE = 'NODE',
ID = 'ID'
}

View file

@ -0,0 +1,110 @@
import {AVLTree, CP} from 'data-structure-typed';
describe('AVL Tree Test from data-structure-typed', () => {
it('should perform various operations on a AVL Tree from data-structure-typed', () => {
const keys = [11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5];
const tree = new AVLTree();
for (const i of keys) tree.add(i, i);
const node6 = tree.get(6);
expect(node6 && tree.getHeight(node6)).toBe(3);
expect(node6 && tree.getDepth(node6)).toBe(1);
const getValueById = tree.get(10);
expect(getValueById).toBe(10);
const getMinNodeByRoot = tree.getLeftMost();
expect(getMinNodeByRoot?.key).toBe(1);
const node15 = tree.getNode(15);
const getMinNodeBySpecificNode = node15 && tree.getLeftMost(node15);
expect(getMinNodeBySpecificNode?.key).toBe(12);
let subTreeSum = 0;
node15 && tree.subTreeTraverse(node => (subTreeSum += node.key), 15);
expect(subTreeSum).toBe(70);
let lesserSum = 0;
tree.lesserOrGreaterTraverse(node => (lesserSum += node.key), CP.lt, 10);
expect(lesserSum).toBe(45);
// node15 has type problem. After the uniform design, the generics of containers (DirectedGraph, BST) are based on the type of value. However, this design has a drawback: when I attempt to inherit from the Vertex or BSTNode classes, the types of the results obtained by all methods are those of the parent class.
expect(node15?.value).toBe(15);
const dfs = tree.dfs(node => node, 'in');
expect(dfs[0].key).toBe(1);
expect(dfs[dfs.length - 1].key).toBe(16);
tree.perfectlyBalance();
const bfs = tree.bfs(node => node);
expect(tree.isPerfectlyBalanced()).toBe(true);
expect(bfs[0].key).toBe(8);
expect(bfs[bfs.length - 1].key).toBe(16);
expect(tree.delete(11)[0].deleted?.key).toBe(11);
expect(tree.isAVLBalanced()).toBe(true);
expect(node15 && tree.getHeight(node15)).toBe(2);
expect(tree.delete(1)[0].deleted?.key).toBe(1);
expect(tree.isAVLBalanced()).toBe(true);
expect(tree.getHeight()).toBe(4);
expect(tree.delete(4)[0].deleted?.key).toBe(4);
expect(tree.isAVLBalanced()).toBe(true);
expect(tree.getHeight()).toBe(4);
expect(tree.delete(10)[0].deleted?.key).toBe(10);
expect(tree.isAVLBalanced()).toBe(true);
expect(tree.getHeight()).toBe(3);
expect(tree.delete(15)[0].deleted?.key).toBe(15);
expect(tree.isAVLBalanced()).toBe(true);
expect(tree.getHeight()).toBe(3);
expect(tree.delete(5)[0].deleted?.key).toBe(5);
expect(tree.isAVLBalanced()).toBe(true);
expect(tree.getHeight()).toBe(3);
expect(tree.delete(13)[0].deleted?.key).toBe(13);
expect(tree.isAVLBalanced()).toBe(true);
expect(tree.getHeight()).toBe(3);
expect(tree.delete(3)[0].deleted?.key).toBe(3);
expect(tree.isAVLBalanced()).toBe(true);
expect(tree.getHeight()).toBe(3);
expect(tree.delete(8)[0].deleted?.key).toBe(8);
expect(tree.isAVLBalanced()).toBe(true);
expect(tree.getHeight()).toBe(3);
expect(tree.delete(6)[0].deleted?.key).toBe(6);
expect(tree.delete(6).length).toBe(0);
expect(tree.isAVLBalanced()).toBe(true);
expect(tree.getHeight()).toBe(2);
expect(tree.delete(7)[0].deleted?.key).toBe(7);
expect(tree.isAVLBalanced()).toBe(true);
expect(tree.getHeight()).toBe(2);
expect(tree.delete(9)[0].deleted?.key).toBe(9);
expect(tree.isAVLBalanced()).toBe(true);
expect(tree.getHeight()).toBe(2);
expect(tree.delete(14)[0].deleted?.key).toBe(14);
expect(tree.isAVLBalanced()).toBe(true);
expect(tree.getHeight()).toBe(1);
expect(tree.isAVLBalanced()).toBe(true);
const lastBFSIds = tree.bfs();
expect(lastBFSIds[0]).toBe(12);
expect(lastBFSIds[1]).toBe(2);
expect(lastBFSIds[2]).toBe(16);
const lastBFSNodes = tree.bfs(node => node);
expect(lastBFSNodes[0].key).toBe(12);
expect(lastBFSNodes[1].key).toBe(2);
expect(lastBFSNodes[2].key).toBe(16);
});
});

View file

@ -107,7 +107,7 @@ const composeReport = () => {
htmlTables // New content to be inserted
);
fs.writeFileSync(htmlFilePath, html);
console.log(`Performance ${BOLD}${GREEN}report${END} file generated`);
console.log(`Performance ${BOLD}${GREEN}report${END} file generated in ${BOLD}${GREEN}${reportDistPath}${END}`);
};
function replaceMarkdownContent(startMarker: string, endMarker: string, newText: string) {
@ -135,7 +135,7 @@ function replaceMarkdownContent(startMarker: string, endMarker: string, newText:
if (err) {
console.error(`Unable to write to ${filePath}:`, err);
} else {
console.log(`The content has been successfully replaced in ${filePath}!`);
console.log(`The content has been successfully replaced in ${BOLD}${GREEN}${filePath}!${END}`);
}
});
});

View file

@ -478,13 +478,13 @@ describe('RedBlackTree', () => {
for (let i = 0; i < arr.length; i++) {
tree.add(arr[i]);
}
console.log(performance.now() - tS);
isDebug && console.log(performance.now() - tS);
const cS = performance.now();
for (let i = 0; i < arr.length; i++) {
competitor.setElement(arr[i], arr[i]);
}
console.log(performance.now() - cS);
isDebug && console.log(performance.now() - cS);
});
});