data-structure-typed 1.54.2 → 1.54.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/LICENSE +2 -2
- package/README.md +14 -1
- package/README_zh-CN.md +1 -1
- package/benchmark/report.html +4 -1
- package/benchmark/report.json +76 -17
- package/dist/cjs/data-structures/binary-tree/avl-tree-counter.d.ts +21 -20
- package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js +8 -7
- package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +12 -12
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +2 -2
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +25 -21
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +12 -8
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +111 -225
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +177 -144
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +59 -53
- package/dist/cjs/data-structures/binary-tree/bst.js +75 -119
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +18 -18
- package/dist/cjs/data-structures/binary-tree/red-black-tree.js +6 -6
- package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-counter.d.ts +19 -19
- package/dist/cjs/data-structures/binary-tree/tree-counter.js +12 -12
- package/dist/cjs/data-structures/binary-tree/tree-counter.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +12 -12
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +2 -2
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -0
- package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +1 -1
- package/dist/cjs/utils/utils.d.ts +2 -2
- package/dist/esm/data-structures/binary-tree/avl-tree-counter.d.ts +21 -20
- package/dist/esm/data-structures/binary-tree/avl-tree-counter.js +9 -8
- package/dist/esm/data-structures/binary-tree/avl-tree-counter.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.d.ts +12 -12
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +3 -3
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/avl-tree.d.ts +25 -21
- package/dist/esm/data-structures/binary-tree/avl-tree.js +13 -9
- package/dist/esm/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/binary-tree.d.ts +111 -225
- package/dist/esm/data-structures/binary-tree/binary-tree.js +181 -148
- package/dist/esm/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/bst.d.ts +59 -53
- package/dist/esm/data-structures/binary-tree/bst.js +76 -120
- package/dist/esm/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/red-black-tree.d.ts +18 -18
- package/dist/esm/data-structures/binary-tree/red-black-tree.js +7 -7
- package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/tree-counter.d.ts +19 -19
- package/dist/esm/data-structures/binary-tree/tree-counter.js +13 -13
- package/dist/esm/data-structures/binary-tree/tree-counter.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +12 -12
- package/dist/esm/data-structures/binary-tree/tree-multi-map.js +3 -3
- package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/esm/types/data-structures/binary-tree/binary-tree.d.ts +1 -0
- package/dist/esm/types/data-structures/binary-tree/bst.d.ts +1 -1
- package/dist/esm/utils/utils.d.ts +2 -2
- package/dist/umd/data-structure-typed.js +296 -279
- package/dist/umd/data-structure-typed.min.js +5 -12
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +7 -7
- package/src/data-structures/binary-tree/avl-tree-counter.ts +30 -23
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +25 -15
- package/src/data-structures/binary-tree/avl-tree.ts +35 -29
- package/src/data-structures/binary-tree/binary-tree.ts +469 -252
- package/src/data-structures/binary-tree/bst.ts +141 -143
- package/src/data-structures/binary-tree/red-black-tree.ts +27 -35
- package/src/data-structures/binary-tree/tree-counter.ts +33 -27
- package/src/data-structures/binary-tree/tree-multi-map.ts +25 -17
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -0
- package/src/types/data-structures/binary-tree/bst.ts +1 -1
- package/src/utils/utils.ts +2 -2
- package/test/integration/compile.mjs +21 -21
- package/test/performance/data-structures/binary-tree/avl-tree.test.mjs +71 -0
- package/test/performance/data-structures/binary-tree/red-black-tree.test.mjs +81 -0
- package/test/performance/{reportor.js → reportor.mjs} +264 -8
- package/test/performance/reportor.ts +1 -1
- package/test/unit/data-structures/binary-tree/avl-tree-counter.test.ts +7 -7
- package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +4 -5
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +72 -5
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +132 -82
- package/test/unit/data-structures/binary-tree/bst.test.ts +12 -12
- package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +4 -12
- package/test/unit/data-structures/binary-tree/tree-counter.test.ts +4 -4
- package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +5 -5
- package/test/utils/json2html.ts +0 -154
- package/test/performance/data-structures/binary-tree/avl-tree.test.js +0 -45
- /package/test/performance/data-structures/binary-tree/{rb-tree.test.ts → red-black-tree.test.ts} +0 -0
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.
|
|
11
|
+
## [v1.54.3](https://github.com/zrwusa/data-structure-typed/compare/v1.51.5...main) (upcoming)
|
|
12
12
|
|
|
13
13
|
### Changes
|
|
14
14
|
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022
|
|
3
|
+
Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -829,6 +829,19 @@ macOS Big Sur
|
|
|
829
829
|
Version 11.7.9
|
|
830
830
|
|
|
831
831
|
***Our performance testing is conducted directly on the TypeScript source code. The actual performance of the compiled JavaScript code is generally 3 times higher. We have compared it with C++, and it is only 30% slower than C++.***
|
|
832
|
+
Try it [on gitpod](https://gitpod.io#snapshot/93383de4-ca4c-4854-8c80-4359e681a96f)
|
|
833
|
+
|
|
834
|
+
Just run
|
|
835
|
+
```shell
|
|
836
|
+
pnpm perf:rbtree
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
```html
|
|
840
|
+
1,000,000 add randomly: 1.367s
|
|
841
|
+
1,000,000 add: 374.859ms
|
|
842
|
+
1,000,000 get: 8.025ms
|
|
843
|
+
1,000,000 getNode: 1.293s
|
|
844
|
+
```
|
|
832
845
|
|
|
833
846
|
[//]: # (No deletion!!! Start of Replace Section)
|
|
834
847
|
<div class="json-to-html-collapse clearfix 0">
|
|
@@ -1004,7 +1017,7 @@ Version 11.7.9
|
|
|
1004
1017
|
<td>Counter</td>
|
|
1005
1018
|
</tr>
|
|
1006
1019
|
<tr>
|
|
1007
|
-
<td>
|
|
1020
|
+
<td>ES6 Map<K, V></td>
|
|
1008
1021
|
<td>-</td>
|
|
1009
1022
|
<td>LinkedHashMap<K, V></td>
|
|
1010
1023
|
<td>OrderedDict</td>
|
package/README_zh-CN.md
CHANGED
|
@@ -1161,7 +1161,7 @@ avl2.print();
|
|
|
1161
1161
|
<div class='collapsible level0' ><span class='json-to-html-label'>bst</span></div>
|
|
1162
1162
|
<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>55.04</td><td>18.17</td><td>0.01</td></tr><tr><td>10,000 add & delete randomly</td><td>129.85</td><td>7.70</td><td>0.01</td></tr><tr><td>10,000 addMany</td><td>50.40</td><td>19.84</td><td>0.01</td></tr><tr><td>10,000 get</td><td>63.39</td><td>15.78</td><td>0.01</td></tr></table></div>
|
|
1163
1163
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
1164
|
-
<div class='collapsible level0' ><span class='json-to-html-label'>
|
|
1164
|
+
<div class='collapsible level0' ><span class='json-to-html-label'>red-black-tree</span></div>
|
|
1165
1165
|
<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>113.25</td><td>8.83</td><td>0.02</td></tr><tr><td>100,000 add & delete randomly</td><td>305.28</td><td>3.28</td><td>0.03</td></tr><tr><td>100,000 getNode</td><td>73.20</td><td>13.66</td><td>0.03</td></tr><tr><td>100,000 add & iterator</td><td>159.80</td><td>6.26</td><td>0.06</td></tr></table></div>
|
|
1166
1166
|
</div><div class="json-to-html-collapse clearfix 0">
|
|
1167
1167
|
<div class='collapsible level0' ><span class='json-to-html-label'>comparison</span></div>
|
package/benchmark/report.html
CHANGED
|
@@ -43,7 +43,10 @@
|
|
|
43
43
|
<body>
|
|
44
44
|
<div id="json-to-html"><div class="json-to-html-collapse clearfix 0">
|
|
45
45
|
<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>
|
|
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>
|
|
47
|
+
</div><div class="json-to-html-collapse clearfix 0">
|
|
48
|
+
<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>
|
|
47
50
|
</div>
|
|
48
51
|
|
|
49
52
|
</div>
|
package/benchmark/report.json
CHANGED
|
@@ -3,47 +3,106 @@
|
|
|
3
3
|
"benchmarks": [
|
|
4
4
|
{
|
|
5
5
|
"test name": "100,000 add randomly",
|
|
6
|
-
"time taken (ms)": "
|
|
7
|
-
"sample mean (secs)": "0.
|
|
6
|
+
"time taken (ms)": "526.46",
|
|
7
|
+
"sample mean (secs)": "0.53",
|
|
8
8
|
"sample deviation": "0.01"
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"test name": "100,000 add",
|
|
12
|
-
"time taken (ms)": "
|
|
13
|
-
"sample mean (secs)": "0.
|
|
12
|
+
"time taken (ms)": "474.38",
|
|
13
|
+
"sample mean (secs)": "0.47",
|
|
14
14
|
"sample deviation": "0.00"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
"test name": "100,000 get",
|
|
18
|
-
"time taken (ms)": "0.
|
|
19
|
-
"sample mean (secs)": "
|
|
20
|
-
"sample deviation": "
|
|
18
|
+
"time taken (ms)": "0.72",
|
|
19
|
+
"sample mean (secs)": "7.17e-4",
|
|
20
|
+
"sample deviation": "3.47e-4"
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
"test name": "100,000 getNode",
|
|
24
|
-
"time taken (ms)": "
|
|
25
|
-
"sample mean (secs)": "0.
|
|
26
|
-
"sample deviation": "0.
|
|
24
|
+
"time taken (ms)": "252.58",
|
|
25
|
+
"sample mean (secs)": "0.25",
|
|
26
|
+
"sample deviation": "0.01"
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
"test name": "100,000 iterator",
|
|
30
|
-
"time taken (ms)": "24.
|
|
30
|
+
"time taken (ms)": "24.84",
|
|
31
31
|
"sample mean (secs)": "0.02",
|
|
32
32
|
"sample deviation": "0.00"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"test name": "100,000 add & delete orderly",
|
|
36
|
-
"time taken (ms)": "
|
|
37
|
-
"sample mean (secs)": "0.
|
|
38
|
-
"sample deviation": "0.
|
|
36
|
+
"time taken (ms)": "717.48",
|
|
37
|
+
"sample mean (secs)": "0.72",
|
|
38
|
+
"sample deviation": "0.02"
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
"test name": "100,000 add & delete randomly",
|
|
42
|
-
"time taken (ms)": "
|
|
43
|
-
"sample mean (secs)": "0.
|
|
44
|
-
"sample deviation": "0.
|
|
42
|
+
"time taken (ms)": "898.45",
|
|
43
|
+
"sample mean (secs)": "0.90",
|
|
44
|
+
"sample deviation": "0.02"
|
|
45
45
|
}
|
|
46
46
|
],
|
|
47
47
|
"testName": "avl-tree"
|
|
48
|
+
},
|
|
49
|
+
"red-black-tree": {
|
|
50
|
+
"benchmarks": [
|
|
51
|
+
{
|
|
52
|
+
"test name": "100,000 add randomly",
|
|
53
|
+
"time taken (ms)": "144.49",
|
|
54
|
+
"sample mean (secs)": "0.14",
|
|
55
|
+
"sample deviation": "0.01"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"test name": "100,000 add",
|
|
59
|
+
"time taken (ms)": "190.53",
|
|
60
|
+
"sample mean (secs)": "0.19",
|
|
61
|
+
"sample deviation": "0.00"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"test name": "100,000 get",
|
|
65
|
+
"time taken (ms)": "0.91",
|
|
66
|
+
"sample mean (secs)": "9.14e-4",
|
|
67
|
+
"sample deviation": "2.11e-4"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"test name": "100,000 getNode",
|
|
71
|
+
"time taken (ms)": "323.66",
|
|
72
|
+
"sample mean (secs)": "0.32",
|
|
73
|
+
"sample deviation": "0.00"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"test name": "100,000 node mode add randomly",
|
|
77
|
+
"time taken (ms)": "139.71",
|
|
78
|
+
"sample mean (secs)": "0.14",
|
|
79
|
+
"sample deviation": "0.00"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"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"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"test name": "100,000 iterator",
|
|
89
|
+
"time taken (ms)": "27.07",
|
|
90
|
+
"sample mean (secs)": "0.03",
|
|
91
|
+
"sample deviation": "0.00"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"test name": "100,000 add & delete orderly",
|
|
95
|
+
"time taken (ms)": "349.17",
|
|
96
|
+
"sample mean (secs)": "0.35",
|
|
97
|
+
"sample deviation": "0.00"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"test name": "100,000 add & delete randomly",
|
|
101
|
+
"time taken (ms)": "482.61",
|
|
102
|
+
"sample mean (secs)": "0.48",
|
|
103
|
+
"sample deviation": "0.01"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"testName": "red-black-tree"
|
|
48
107
|
}
|
|
49
108
|
}
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import type { AVLTreeCounterOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode,
|
|
8
|
+
import type { AVLTreeCounterOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, EntryCallback, IterationType } from '../../types';
|
|
9
9
|
import { IBinaryTree } from '../../interfaces';
|
|
10
10
|
import { AVLTree, AVLTreeNode } from './avl-tree';
|
|
11
11
|
export declare class AVLTreeCounterNode<K = any, V = any> extends AVLTreeNode<K, V> {
|
|
12
|
+
parent?: AVLTreeCounterNode<K, V>;
|
|
12
13
|
/**
|
|
13
14
|
* The constructor function initializes a BinaryTreeNode object with a key, value, and count.
|
|
14
15
|
* @param {K} key - The `key` parameter is of type `K` and represents the unique identifier
|
|
@@ -20,13 +21,12 @@ export declare class AVLTreeCounterNode<K = any, V = any> extends AVLTreeNode<K,
|
|
|
20
21
|
* parameter when creating a new instance of the `BinaryTreeNode` class.
|
|
21
22
|
*/
|
|
22
23
|
constructor(key: K, value?: V, count?: number);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
set right(v: OptNodeOrNull<AVLTreeCounterNode<K, V>>);
|
|
24
|
+
_left?: AVLTreeCounterNode<K, V> | null | undefined;
|
|
25
|
+
get left(): AVLTreeCounterNode<K, V> | null | undefined;
|
|
26
|
+
set left(v: AVLTreeCounterNode<K, V> | null | undefined);
|
|
27
|
+
_right?: AVLTreeCounterNode<K, V> | null | undefined;
|
|
28
|
+
get right(): AVLTreeCounterNode<K, V> | null | undefined;
|
|
29
|
+
set right(v: AVLTreeCounterNode<K, V> | null | undefined);
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* The only distinction between a AVLTreeCounter and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
|
|
@@ -40,7 +40,7 @@ export declare class AVLTreeCounter<K = any, V = any, R = object, MK = any, MV =
|
|
|
40
40
|
* behavior of the AVLTreeCounter. It can include properties such as `compareKeys` and
|
|
41
41
|
* `compareValues` functions to define custom comparison logic for keys and values, respectively.
|
|
42
42
|
*/
|
|
43
|
-
constructor(keysNodesEntriesOrRaws?: Iterable<
|
|
43
|
+
constructor(keysNodesEntriesOrRaws?: Iterable<K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, options?: AVLTreeCounterOptions<K, V, R>);
|
|
44
44
|
protected _count: number;
|
|
45
45
|
/**
|
|
46
46
|
* The function calculates the sum of the count property of all nodes in a tree using depth-first
|
|
@@ -79,21 +79,21 @@ export declare class AVLTreeCounter<K = any, V = any, R = object, MK = any, MV =
|
|
|
79
79
|
createTree(options?: AVLTreeCounterOptions<K, V, R>): AVLTreeCounter<K, V, R, MK, MV, MR>;
|
|
80
80
|
/**
|
|
81
81
|
* The function checks if the input is an instance of AVLTreeCounterNode.
|
|
82
|
-
* @param {
|
|
83
|
-
* `keyNodeOrEntry` can be of type `R` or `
|
|
82
|
+
* @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The parameter
|
|
83
|
+
* `keyNodeOrEntry` can be of type `R` or `K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`.
|
|
84
84
|
* @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
|
|
85
85
|
* an instance of the `AVLTreeCounterNode` class.
|
|
86
86
|
*/
|
|
87
|
-
isNode(keyNodeOrEntry:
|
|
87
|
+
isNode(keyNodeOrEntry: K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is AVLTreeCounterNode<K, V>;
|
|
88
88
|
/**
|
|
89
89
|
* Time Complexity: O(log n)
|
|
90
90
|
* Space Complexity: O(1)
|
|
91
91
|
*
|
|
92
92
|
* The function overrides the add method of a TypeScript class to add a new node to a data structure
|
|
93
93
|
* and update the count.
|
|
94
|
-
* @param {
|
|
94
|
+
* @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The
|
|
95
95
|
* `keyNodeOrEntry` parameter can accept a value of type `R`, which can be any type. It
|
|
96
|
-
* can also accept a value of type `
|
|
96
|
+
* can also accept a value of type `K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`, which represents a key, node,
|
|
97
97
|
* entry, or raw element
|
|
98
98
|
* @param {V} [value] - The `value` parameter represents the value associated with the key in the
|
|
99
99
|
* data structure. It is an optional parameter, so it can be omitted if not needed.
|
|
@@ -102,14 +102,14 @@ export declare class AVLTreeCounter<K = any, V = any, R = object, MK = any, MV =
|
|
|
102
102
|
* be added once. However, you can specify a different value for `count` if you want to add
|
|
103
103
|
* @returns a boolean value.
|
|
104
104
|
*/
|
|
105
|
-
add(keyNodeOrEntry:
|
|
105
|
+
add(keyNodeOrEntry: K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V, count?: number): boolean;
|
|
106
106
|
/**
|
|
107
107
|
* Time Complexity: O(log n)
|
|
108
108
|
* Space Complexity: O(1)
|
|
109
109
|
*
|
|
110
110
|
* The function overrides the delete method in a binary tree data structure, handling deletion of
|
|
111
111
|
* nodes and maintaining balance in the tree.
|
|
112
|
-
* @param {
|
|
112
|
+
* @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The `predicate`
|
|
113
113
|
* parameter in the `delete` method is used to specify the condition for deleting a node from the
|
|
114
114
|
* binary tree. It can be a key, node, or entry that determines which
|
|
115
115
|
* node(s) should be deleted.
|
|
@@ -122,7 +122,7 @@ export declare class AVLTreeCounter<K = any, V = any, R = object, MK = any, MV =
|
|
|
122
122
|
* method returns an array of `BinaryTreeDeleteResult` objects, each containing information about the
|
|
123
123
|
* deleted node and whether balancing is needed in the tree.
|
|
124
124
|
*/
|
|
125
|
-
delete(keyNodeOrEntry:
|
|
125
|
+
delete(keyNodeOrEntry: K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, ignoreCount?: boolean): BinaryTreeDeleteResult<AVLTreeCounterNode<K, V>>[];
|
|
126
126
|
/**
|
|
127
127
|
* Time Complexity: O(1)
|
|
128
128
|
* Space Complexity: O(1)
|
|
@@ -134,6 +134,7 @@ export declare class AVLTreeCounter<K = any, V = any, R = object, MK = any, MV =
|
|
|
134
134
|
/**
|
|
135
135
|
* Time Complexity: O(n log n)
|
|
136
136
|
* Space Complexity: O(log n)
|
|
137
|
+
*
|
|
137
138
|
* The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
|
|
138
139
|
* tree using either a recursive or iterative approach.
|
|
139
140
|
* @param {IterationType} iterationType - The `iterationType` parameter is an optional parameter that
|
|
@@ -174,8 +175,8 @@ export declare class AVLTreeCounter<K = any, V = any, R = object, MK = any, MV =
|
|
|
174
175
|
/**
|
|
175
176
|
* The function `keyValueNodeEntryRawToNodeAndValue` converts a key, value, entry, or raw element into
|
|
176
177
|
* a node object.
|
|
177
|
-
* @param {
|
|
178
|
-
* `keyNodeOrEntry` parameter can be of type `R` or `
|
|
178
|
+
* @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The
|
|
179
|
+
* `keyNodeOrEntry` parameter can be of type `R` or `K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`.
|
|
179
180
|
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
|
|
180
181
|
* `override` function. It represents the value associated with the key in the data structure. If no
|
|
181
182
|
* value is provided, it will default to `undefined`.
|
|
@@ -183,7 +184,7 @@ export declare class AVLTreeCounter<K = any, V = any, R = object, MK = any, MV =
|
|
|
183
184
|
* times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
|
|
184
185
|
* @returns either a AVLTreeCounterNode<K, V> object or undefined.
|
|
185
186
|
*/
|
|
186
|
-
protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry:
|
|
187
|
+
protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry: K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V, count?: number): [AVLTreeCounterNode<K, V> | undefined, V | undefined];
|
|
187
188
|
/**
|
|
188
189
|
* Time Complexity: O(1)
|
|
189
190
|
* Space Complexity: O(1)
|
|
@@ -105,8 +105,8 @@ class AVLTreeCounter extends avl_tree_1.AVLTree {
|
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
107
|
* The function checks if the input is an instance of AVLTreeCounterNode.
|
|
108
|
-
* @param {
|
|
109
|
-
* `keyNodeOrEntry` can be of type `R` or `
|
|
108
|
+
* @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The parameter
|
|
109
|
+
* `keyNodeOrEntry` can be of type `R` or `K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`.
|
|
110
110
|
* @returns a boolean value indicating whether the input parameter `keyNodeOrEntry` is
|
|
111
111
|
* an instance of the `AVLTreeCounterNode` class.
|
|
112
112
|
*/
|
|
@@ -119,9 +119,9 @@ class AVLTreeCounter extends avl_tree_1.AVLTree {
|
|
|
119
119
|
*
|
|
120
120
|
* The function overrides the add method of a TypeScript class to add a new node to a data structure
|
|
121
121
|
* and update the count.
|
|
122
|
-
* @param {
|
|
122
|
+
* @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The
|
|
123
123
|
* `keyNodeOrEntry` parameter can accept a value of type `R`, which can be any type. It
|
|
124
|
-
* can also accept a value of type `
|
|
124
|
+
* can also accept a value of type `K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`, which represents a key, node,
|
|
125
125
|
* entry, or raw element
|
|
126
126
|
* @param {V} [value] - The `value` parameter represents the value associated with the key in the
|
|
127
127
|
* data structure. It is an optional parameter, so it can be omitted if not needed.
|
|
@@ -147,7 +147,7 @@ class AVLTreeCounter extends avl_tree_1.AVLTree {
|
|
|
147
147
|
*
|
|
148
148
|
* The function overrides the delete method in a binary tree data structure, handling deletion of
|
|
149
149
|
* nodes and maintaining balance in the tree.
|
|
150
|
-
* @param {
|
|
150
|
+
* @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The `predicate`
|
|
151
151
|
* parameter in the `delete` method is used to specify the condition for deleting a node from the
|
|
152
152
|
* binary tree. It can be a key, node, or entry that determines which
|
|
153
153
|
* node(s) should be deleted.
|
|
@@ -232,6 +232,7 @@ class AVLTreeCounter extends avl_tree_1.AVLTree {
|
|
|
232
232
|
/**
|
|
233
233
|
* Time Complexity: O(n log n)
|
|
234
234
|
* Space Complexity: O(log n)
|
|
235
|
+
*
|
|
235
236
|
* The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
|
|
236
237
|
* tree using either a recursive or iterative approach.
|
|
237
238
|
* @param {IterationType} iterationType - The `iterationType` parameter is an optional parameter that
|
|
@@ -329,8 +330,8 @@ class AVLTreeCounter extends avl_tree_1.AVLTree {
|
|
|
329
330
|
/**
|
|
330
331
|
* The function `keyValueNodeEntryRawToNodeAndValue` converts a key, value, entry, or raw element into
|
|
331
332
|
* a node object.
|
|
332
|
-
* @param {
|
|
333
|
-
* `keyNodeOrEntry` parameter can be of type `R` or `
|
|
333
|
+
* @param {K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined} keyNodeOrEntry - The
|
|
334
|
+
* `keyNodeOrEntry` parameter can be of type `R` or `K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined`.
|
|
334
335
|
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
|
|
335
336
|
* `override` function. It represents the value associated with the key in the data structure. If no
|
|
336
337
|
* value is provided, it will default to `undefined`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avl-tree-counter.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/avl-tree-counter.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"avl-tree-counter.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/avl-tree-counter.ts"],"names":[],"mappings":";;;AAeA,yCAAkD;AAElD,MAAa,kBAAqC,SAAQ,sBAAiB;IAGzE;;;;;;;;;OASG;IACH,YAAY,GAAM,EAAE,KAAS,EAAE,KAAK,GAAG,CAAC;QACtC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAbX,WAAM,GAA8B,SAAS,CAAC;QAiB9C,UAAK,GAAiD,SAAS,CAAC;QAahE,WAAM,GAAiD,SAAS,CAAC;QAhBxE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAID,IAAa,IAAI;QACf,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAa,IAAI,CAAC,CAA8C;QAC9D,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IAID,IAAa,KAAK;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAa,KAAK,CAAC,CAA8C;QAC/D,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;CACF;AA3CD,gDA2CC;AAED;;GAEG;AACH,MAAa,cACX,SAAQ,kBAA4B;IAGpC;;;;;;;OAOG;IACH,YACE,yBAEI,EAAE,EACN,OAAwC;QAExC,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAIX,WAAM,GAAG,CAAC,CAAC;QAHnB,IAAI,sBAAsB;YAAE,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAA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,MAAM,CAAC;gBAEjC,OAAO,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;gBAC3B,IAAI,CAAC,IAAI,CAAC,UAAU;oBAAE,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;gBACrD,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;gBAC/B,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;YACnC,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;;;;;OAUG;IACgB,YAAY,CAC7B,OAAiC,EACjC,OAAiC;QAEjC,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC9C,OAAO,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACF;AApZD,wCAoZC"}
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import { AVLTreeMultiMapOptions
|
|
8
|
+
import { AVLTreeMultiMapOptions } from '../../types';
|
|
9
9
|
import { AVLTree, AVLTreeNode } from './avl-tree';
|
|
10
10
|
import { IBinaryTree } from '../../interfaces';
|
|
11
11
|
export declare class AVLTreeMultiMapNode<K = any, V = any> extends AVLTreeNode<K, V[]> {
|
|
12
|
+
parent?: AVLTreeMultiMapNode<K, V>;
|
|
12
13
|
/**
|
|
13
14
|
* This TypeScript constructor initializes an object with a key of type K and an array of values of
|
|
14
15
|
* type V.
|
|
@@ -19,13 +20,12 @@ export declare class AVLTreeMultiMapNode<K = any, V = any> extends AVLTreeNode<K
|
|
|
19
20
|
* type `V`.
|
|
20
21
|
*/
|
|
21
22
|
constructor(key: K, value: V[]);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
set right(v: OptNodeOrNull<AVLTreeMultiMapNode<K, V>>);
|
|
23
|
+
_left?: AVLTreeMultiMapNode<K, V> | null | undefined;
|
|
24
|
+
get left(): AVLTreeMultiMapNode<K, V> | null | undefined;
|
|
25
|
+
set left(v: AVLTreeMultiMapNode<K, V> | null | undefined);
|
|
26
|
+
_right?: AVLTreeMultiMapNode<K, V> | null | undefined;
|
|
27
|
+
get right(): AVLTreeMultiMapNode<K, V> | null | undefined;
|
|
28
|
+
set right(v: AVLTreeMultiMapNode<K, V> | null | undefined);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
*
|
|
@@ -42,7 +42,7 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = object, MK = any, MV
|
|
|
42
42
|
* `AVLTreeMultiMapOptions<K, V[], R>`. It is an optional parameter that allows you to specify
|
|
43
43
|
* additional options for configuring the AVLTreeMultiMap instance.
|
|
44
44
|
*/
|
|
45
|
-
constructor(keysNodesEntriesOrRaws?: Iterable<
|
|
45
|
+
constructor(keysNodesEntriesOrRaws?: Iterable<K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | R>, options?: AVLTreeMultiMapOptions<K, V[], R>);
|
|
46
46
|
/**
|
|
47
47
|
* Time Complexity: O(1)
|
|
48
48
|
* Space Complexity: O(1)
|
|
@@ -68,7 +68,7 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = object, MK = any, MV
|
|
|
68
68
|
* empty array.
|
|
69
69
|
*/
|
|
70
70
|
createNode(key: K): AVLTreeMultiMapNode<K, V>;
|
|
71
|
-
add(node:
|
|
71
|
+
add(node: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined): boolean;
|
|
72
72
|
add(key: K, value: V): boolean;
|
|
73
73
|
/**
|
|
74
74
|
* Time Complexity: O(log n)
|
|
@@ -76,7 +76,7 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = object, MK = any, MV
|
|
|
76
76
|
*
|
|
77
77
|
* The function `deleteValue` removes a specific value from a key in an AVLTreeMultiMap data
|
|
78
78
|
* structure and deletes the entire node if no values are left for that key.
|
|
79
|
-
* @param {
|
|
79
|
+
* @param {K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | K} keyNodeOrEntry - The `keyNodeOrEntry`
|
|
80
80
|
* parameter in the `deleteValue` function can be either a `BTNRep` object representing a key-value
|
|
81
81
|
* pair in the AVLTreeMultiMapNode, or just the key itself.
|
|
82
82
|
* @param {V} value - The `value` parameter in the `deleteValue` function represents the specific
|
|
@@ -87,7 +87,7 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = object, MK = any, MV
|
|
|
87
87
|
* `value` was successfully deleted from the array of values associated with the `keyNodeOrEntry`. If
|
|
88
88
|
* the value was not found in the array, it returns `false`.
|
|
89
89
|
*/
|
|
90
|
-
deleteValue(keyNodeOrEntry:
|
|
90
|
+
deleteValue(keyNodeOrEntry: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | K, value: V): boolean;
|
|
91
91
|
/**
|
|
92
92
|
* Time Complexity: O(n)
|
|
93
93
|
* Space Complexity: O(n)
|
|
@@ -94,7 +94,7 @@ class AVLTreeMultiMap extends avl_tree_1.AVLTree {
|
|
|
94
94
|
*
|
|
95
95
|
* The function `add` in TypeScript overrides the superclass method to add key-value pairs to an AVL
|
|
96
96
|
* tree multi-map.
|
|
97
|
-
* @param {
|
|
97
|
+
* @param {K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | K} keyNodeOrEntry - The `keyNodeOrEntry`
|
|
98
98
|
* parameter in the `override add` method can be either a key-value pair entry or just a key. If it
|
|
99
99
|
* is a key-value pair entry, it will be in the format `[key, values]`, where `key` is the key and
|
|
100
100
|
* `values`
|
|
@@ -147,7 +147,7 @@ class AVLTreeMultiMap extends avl_tree_1.AVLTree {
|
|
|
147
147
|
*
|
|
148
148
|
* The function `deleteValue` removes a specific value from a key in an AVLTreeMultiMap data
|
|
149
149
|
* structure and deletes the entire node if no values are left for that key.
|
|
150
|
-
* @param {
|
|
150
|
+
* @param {K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | K} keyNodeOrEntry - The `keyNodeOrEntry`
|
|
151
151
|
* parameter in the `deleteValue` function can be either a `BTNRep` object representing a key-value
|
|
152
152
|
* pair in the AVLTreeMultiMapNode, or just the key itself.
|
|
153
153
|
* @param {V} value - The `value` parameter in the `deleteValue` function represents the specific
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avl-tree-multi-map.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/avl-tree-multi-map.ts"],"names":[],"mappings":";;;AAQA,yCAAkD;AAGlD,MAAa,mBAAsC,SAAQ,sBAAmB;
|
|
1
|
+
{"version":3,"file":"avl-tree-multi-map.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/avl-tree-multi-map.ts"],"names":[],"mappings":";;;AAQA,yCAAkD;AAGlD,MAAa,mBAAsC,SAAQ,sBAAmB;IAG5E;;;;;;;;OAQG;IACH,YAAY,GAAM,EAAE,KAAU;QAC5B,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAZX,WAAM,GAA+B,SAAS,CAAC;QAe/C,UAAK,GAAkD,SAAS,CAAC;QAajE,WAAM,GAAkD,SAAS,CAAC;IAf3E,CAAC;IAID,IAAa,IAAI;QACf,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAa,IAAI,CAAC,CAA+C;QAC/D,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IAID,IAAa,KAAK;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAA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