data-structure-typed 1.52.9 → 1.53.1
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/README.md +13 -13
- package/benchmark/report.html +1 -37
- package/benchmark/report.json +24 -384
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +21 -21
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +64 -47
- 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 +20 -20
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +29 -27
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +186 -144
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +376 -265
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +56 -56
- package/dist/cjs/data-structures/binary-tree/bst.js +108 -78
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +13 -13
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +42 -36
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +21 -21
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +59 -49
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.js +3 -3
- package/dist/cjs/interfaces/binary-tree.d.ts +5 -5
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +13 -13
- package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +3 -3
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +21 -21
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +64 -46
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +20 -20
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +29 -26
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +186 -144
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +376 -264
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +56 -56
- package/dist/mjs/data-structures/binary-tree/bst.js +108 -76
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +13 -13
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +42 -35
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +21 -21
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +59 -48
- package/dist/mjs/data-structures/trie/trie.js +3 -3
- package/dist/mjs/interfaces/binary-tree.d.ts +5 -5
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +13 -13
- package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +3 -3
- package/dist/umd/data-structure-typed.js +596 -468
- package/dist/umd/data-structure-typed.min.js +5 -5
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +6 -6
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +60 -54
- package/src/data-structures/binary-tree/avl-tree.ts +32 -35
- package/src/data-structures/binary-tree/binary-tree.ts +440 -360
- package/src/data-structures/binary-tree/bst.ts +144 -113
- package/src/data-structures/binary-tree/rb-tree.ts +44 -43
- package/src/data-structures/binary-tree/tree-multi-map.ts +57 -61
- package/src/data-structures/trie/trie.ts +3 -3
- package/src/interfaces/binary-tree.ts +6 -6
- package/src/types/data-structures/binary-tree/binary-tree.ts +13 -14
- package/src/types/data-structures/binary-tree/bst.ts +3 -3
- package/test/performance/data-structures/binary-tree/binary-tree-overall.test.ts +2 -2
- package/test/performance/data-structures/binary-tree/rb-tree.test.ts +9 -1
- package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +115 -3
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +109 -4
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +183 -46
- package/test/unit/data-structures/binary-tree/bst.test.ts +340 -21
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +19 -0
- package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +141 -3
- package/test/utils/array.ts +15 -12
package/benchmark/report.json
CHANGED
|
@@ -1,415 +1,55 @@
|
|
|
1
1
|
{
|
|
2
|
-
"heap": {
|
|
3
|
-
"benchmarks": [
|
|
4
|
-
{
|
|
5
|
-
"test name": "100,000 add",
|
|
6
|
-
"time taken (ms)": "6.66",
|
|
7
|
-
"executions per sec": "150.18",
|
|
8
|
-
"sample deviation": "2.19e-4"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"test name": "100,000 add & poll",
|
|
12
|
-
"time taken (ms)": "35.35",
|
|
13
|
-
"executions per sec": "28.29",
|
|
14
|
-
"sample deviation": "8.55e-4"
|
|
15
|
-
}
|
|
16
|
-
],
|
|
17
|
-
"testName": "heap"
|
|
18
|
-
},
|
|
19
2
|
"rb-tree": {
|
|
20
3
|
"benchmarks": [
|
|
21
4
|
{
|
|
22
5
|
"test name": "100,000 add",
|
|
23
|
-
"time taken (ms)": "
|
|
24
|
-
"executions per sec": "11.95",
|
|
25
|
-
"sample deviation": "4.47e-4"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"test name": "100,000 add randomly",
|
|
29
|
-
"time taken (ms)": "85.05",
|
|
6
|
+
"time taken (ms)": "85.02",
|
|
30
7
|
"executions per sec": "11.76",
|
|
31
|
-
"sample deviation": "
|
|
8
|
+
"sample deviation": "5.42e-4"
|
|
32
9
|
},
|
|
33
10
|
{
|
|
34
|
-
"test name": "100,000
|
|
35
|
-
"time taken (ms)": "
|
|
36
|
-
"executions per sec": "
|
|
37
|
-
"sample deviation": "0.00"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"test name": "100,000 iterator",
|
|
41
|
-
"time taken (ms)": "23.62",
|
|
42
|
-
"executions per sec": "42.34",
|
|
43
|
-
"sample deviation": "0.00"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"test name": "100,000 add & delete orderly",
|
|
47
|
-
"time taken (ms)": "153.38",
|
|
48
|
-
"executions per sec": "6.52",
|
|
49
|
-
"sample deviation": "0.01"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"test name": "100,000 add & delete randomly",
|
|
53
|
-
"time taken (ms)": "232.75",
|
|
54
|
-
"executions per sec": "4.30",
|
|
55
|
-
"sample deviation": "0.00"
|
|
56
|
-
}
|
|
57
|
-
],
|
|
58
|
-
"testName": "rb-tree"
|
|
59
|
-
},
|
|
60
|
-
"queue": {
|
|
61
|
-
"benchmarks": [
|
|
62
|
-
{
|
|
63
|
-
"test name": "1,000,000 push",
|
|
64
|
-
"time taken (ms)": "46.18",
|
|
65
|
-
"executions per sec": "21.65",
|
|
11
|
+
"test name": "100,000 add randomly",
|
|
12
|
+
"time taken (ms)": "101.88",
|
|
13
|
+
"executions per sec": "9.82",
|
|
66
14
|
"sample deviation": "0.01"
|
|
67
15
|
},
|
|
68
16
|
{
|
|
69
|
-
"test name": "100,000
|
|
70
|
-
"time taken (ms)": "
|
|
71
|
-
"executions per sec": "
|
|
72
|
-
"sample deviation": "
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"test name": "Native JS Array 100,000 push & shift",
|
|
76
|
-
"time taken (ms)": "2273.18",
|
|
77
|
-
"executions per sec": "0.44",
|
|
78
|
-
"sample deviation": "0.20"
|
|
79
|
-
}
|
|
80
|
-
],
|
|
81
|
-
"testName": "queue"
|
|
82
|
-
},
|
|
83
|
-
"deque": {
|
|
84
|
-
"benchmarks": [
|
|
85
|
-
{
|
|
86
|
-
"test name": "1,000,000 push",
|
|
87
|
-
"time taken (ms)": "20.33",
|
|
88
|
-
"executions per sec": "49.20",
|
|
89
|
-
"sample deviation": "0.00"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"test name": "1,000,000 push & pop",
|
|
93
|
-
"time taken (ms)": "26.35",
|
|
94
|
-
"executions per sec": "37.95",
|
|
95
|
-
"sample deviation": "0.00"
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"test name": "1,000,000 push & shift",
|
|
99
|
-
"time taken (ms)": "28.83",
|
|
100
|
-
"executions per sec": "34.68",
|
|
101
|
-
"sample deviation": "0.00"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"test name": "100,000 push & shift",
|
|
105
|
-
"time taken (ms)": "2.55",
|
|
106
|
-
"executions per sec": "392.71",
|
|
107
|
-
"sample deviation": "3.48e-4"
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
"test name": "Native JS Array 100,000 push & shift",
|
|
111
|
-
"time taken (ms)": "2285.23",
|
|
112
|
-
"executions per sec": "0.44",
|
|
113
|
-
"sample deviation": "0.25"
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"test name": "100,000 unshift & shift",
|
|
117
|
-
"time taken (ms)": "2.53",
|
|
118
|
-
"executions per sec": "395.88",
|
|
119
|
-
"sample deviation": "4.03e-4"
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
"test name": "Native JS Array 100,000 unshift & shift",
|
|
123
|
-
"time taken (ms)": "4063.57",
|
|
124
|
-
"executions per sec": "0.25",
|
|
125
|
-
"sample deviation": "0.22"
|
|
126
|
-
}
|
|
127
|
-
],
|
|
128
|
-
"testName": "deque"
|
|
129
|
-
},
|
|
130
|
-
"hash-map": {
|
|
131
|
-
"benchmarks": [
|
|
132
|
-
{
|
|
133
|
-
"test name": "1,000,000 set",
|
|
134
|
-
"time taken (ms)": "210.30",
|
|
135
|
-
"executions per sec": "4.76",
|
|
136
|
-
"sample deviation": "0.03"
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
"test name": "Native JS Map 1,000,000 set",
|
|
140
|
-
"time taken (ms)": "217.28",
|
|
141
|
-
"executions per sec": "4.60",
|
|
142
|
-
"sample deviation": "0.03"
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
"test name": "Native JS Set 1,000,000 add",
|
|
146
|
-
"time taken (ms)": "175.11",
|
|
147
|
-
"executions per sec": "5.71",
|
|
148
|
-
"sample deviation": "0.02"
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
"test name": "1,000,000 set & get",
|
|
152
|
-
"time taken (ms)": "231.89",
|
|
153
|
-
"executions per sec": "4.31",
|
|
154
|
-
"sample deviation": "0.05"
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
"test name": "Native JS Map 1,000,000 set & get",
|
|
158
|
-
"time taken (ms)": "278.86",
|
|
159
|
-
"executions per sec": "3.59",
|
|
160
|
-
"sample deviation": "0.03"
|
|
17
|
+
"test name": "100,000 get",
|
|
18
|
+
"time taken (ms)": "1.08",
|
|
19
|
+
"executions per sec": "921.67",
|
|
20
|
+
"sample deviation": "7.93e-5"
|
|
161
21
|
},
|
|
162
22
|
{
|
|
163
|
-
"test name": "
|
|
164
|
-
"time taken (ms)": "
|
|
165
|
-
"executions per sec": "
|
|
23
|
+
"test name": "100,000 node mode add randomly",
|
|
24
|
+
"time taken (ms)": "107.93",
|
|
25
|
+
"executions per sec": "9.27",
|
|
166
26
|
"sample deviation": "0.01"
|
|
167
27
|
},
|
|
168
28
|
{
|
|
169
|
-
"test name": "
|
|
170
|
-
"time taken (ms)": "
|
|
171
|
-
"executions per sec": "
|
|
172
|
-
"sample deviation": "
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
"test name": "Native JS Map 1,000,000 ObjKey set & get",
|
|
176
|
-
"time taken (ms)": "348.73",
|
|
177
|
-
"executions per sec": "2.87",
|
|
178
|
-
"sample deviation": "0.07"
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
"test name": "Native JS Set 1,000,000 ObjKey add & has",
|
|
182
|
-
"time taken (ms)": "295.33",
|
|
183
|
-
"executions per sec": "3.39",
|
|
184
|
-
"sample deviation": "0.04"
|
|
185
|
-
}
|
|
186
|
-
],
|
|
187
|
-
"testName": "hash-map"
|
|
188
|
-
},
|
|
189
|
-
"trie": {
|
|
190
|
-
"benchmarks": [
|
|
191
|
-
{
|
|
192
|
-
"test name": "100,000 push",
|
|
193
|
-
"time taken (ms)": "43.24",
|
|
194
|
-
"executions per sec": "23.13",
|
|
195
|
-
"sample deviation": "6.15e-4"
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
"test name": "100,000 getWords",
|
|
199
|
-
"time taken (ms)": "105.06",
|
|
200
|
-
"executions per sec": "9.52",
|
|
201
|
-
"sample deviation": "0.01"
|
|
202
|
-
}
|
|
203
|
-
],
|
|
204
|
-
"testName": "trie"
|
|
205
|
-
},
|
|
206
|
-
"avl-tree": {
|
|
207
|
-
"benchmarks": [
|
|
208
|
-
{
|
|
209
|
-
"test name": "100,000 add",
|
|
210
|
-
"time taken (ms)": "309.91",
|
|
211
|
-
"executions per sec": "3.23",
|
|
212
|
-
"sample deviation": "0.01"
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
"test name": "100,000 add randomly",
|
|
216
|
-
"time taken (ms)": "368.42",
|
|
217
|
-
"executions per sec": "2.71",
|
|
218
|
-
"sample deviation": "0.00"
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
"test name": "100,000 get",
|
|
222
|
-
"time taken (ms)": "171.25",
|
|
223
|
-
"executions per sec": "5.84",
|
|
224
|
-
"sample deviation": "0.00"
|
|
29
|
+
"test name": "100,000 node mode get",
|
|
30
|
+
"time taken (ms)": "2.80",
|
|
31
|
+
"executions per sec": "357.71",
|
|
32
|
+
"sample deviation": "1.91e-4"
|
|
225
33
|
},
|
|
226
34
|
{
|
|
227
35
|
"test name": "100,000 iterator",
|
|
228
|
-
"time taken (ms)": "
|
|
229
|
-
"executions per sec": "
|
|
230
|
-
"sample deviation": "0.
|
|
36
|
+
"time taken (ms)": "36.99",
|
|
37
|
+
"executions per sec": "27.04",
|
|
38
|
+
"sample deviation": "0.01"
|
|
231
39
|
},
|
|
232
40
|
{
|
|
233
41
|
"test name": "100,000 add & delete orderly",
|
|
234
|
-
"time taken (ms)": "
|
|
235
|
-
"executions per sec": "
|
|
42
|
+
"time taken (ms)": "158.77",
|
|
43
|
+
"executions per sec": "6.30",
|
|
236
44
|
"sample deviation": "0.00"
|
|
237
45
|
},
|
|
238
46
|
{
|
|
239
47
|
"test name": "100,000 add & delete randomly",
|
|
240
|
-
"time taken (ms)": "
|
|
241
|
-
"executions per sec": "
|
|
242
|
-
"sample deviation": "0.02"
|
|
243
|
-
}
|
|
244
|
-
],
|
|
245
|
-
"testName": "avl-tree"
|
|
246
|
-
},
|
|
247
|
-
"binary-tree-overall": {
|
|
248
|
-
"benchmarks": [
|
|
249
|
-
{
|
|
250
|
-
"test name": "10,000 RBTree add randomly",
|
|
251
|
-
"time taken (ms)": "7.30",
|
|
252
|
-
"executions per sec": "136.94",
|
|
253
|
-
"sample deviation": "9.11e-5"
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
"test name": "10,000 RBTree get randomly",
|
|
257
|
-
"time taken (ms)": "12.92",
|
|
258
|
-
"executions per sec": "77.41",
|
|
259
|
-
"sample deviation": "1.62e-4"
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
"test name": "10,000 RBTree add & delete randomly",
|
|
263
|
-
"time taken (ms)": "22.42",
|
|
264
|
-
"executions per sec": "44.60",
|
|
265
|
-
"sample deviation": "3.28e-4"
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
"test name": "10,000 AVLTree add randomly",
|
|
269
|
-
"time taken (ms)": "28.34",
|
|
270
|
-
"executions per sec": "35.29",
|
|
271
|
-
"sample deviation": "3.30e-4"
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
"test name": "10,000 AVLTree get randomly",
|
|
275
|
-
"time taken (ms)": "12.94",
|
|
276
|
-
"executions per sec": "77.27",
|
|
277
|
-
"sample deviation": "8.60e-5"
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
"test name": "10,000 AVLTree add & delete randomly",
|
|
281
|
-
"time taken (ms)": "52.35",
|
|
282
|
-
"executions per sec": "19.10",
|
|
283
|
-
"sample deviation": "5.13e-4"
|
|
284
|
-
}
|
|
285
|
-
],
|
|
286
|
-
"testName": "binary-tree-overall"
|
|
287
|
-
},
|
|
288
|
-
"directed-graph": {
|
|
289
|
-
"benchmarks": [
|
|
290
|
-
{
|
|
291
|
-
"test name": "1,000 addVertex",
|
|
292
|
-
"time taken (ms)": "0.09",
|
|
293
|
-
"executions per sec": "1.07e+4",
|
|
294
|
-
"sample deviation": "8.73e-7"
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
"test name": "1,000 addEdge",
|
|
298
|
-
"time taken (ms)": "5.98",
|
|
299
|
-
"executions per sec": "167.36",
|
|
300
|
-
"sample deviation": "1.15e-4"
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
"test name": "1,000 getVertex",
|
|
304
|
-
"time taken (ms)": "0.09",
|
|
305
|
-
"executions per sec": "1.05e+4",
|
|
306
|
-
"sample deviation": "8.10e-7"
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
"test name": "1,000 getEdge",
|
|
310
|
-
"time taken (ms)": "23.42",
|
|
311
|
-
"executions per sec": "42.69",
|
|
312
|
-
"sample deviation": "0.00"
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
"test name": "tarjan",
|
|
316
|
-
"time taken (ms)": "210.66",
|
|
317
|
-
"executions per sec": "4.75",
|
|
318
|
-
"sample deviation": "0.04"
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
"test name": "topologicalSort",
|
|
322
|
-
"time taken (ms)": "152.36",
|
|
323
|
-
"executions per sec": "6.56",
|
|
324
|
-
"sample deviation": "0.01"
|
|
325
|
-
}
|
|
326
|
-
],
|
|
327
|
-
"testName": "directed-graph"
|
|
328
|
-
},
|
|
329
|
-
"doubly-linked-list": {
|
|
330
|
-
"benchmarks": [
|
|
331
|
-
{
|
|
332
|
-
"test name": "1,000,000 push",
|
|
333
|
-
"time taken (ms)": "196.74",
|
|
334
|
-
"executions per sec": "5.08",
|
|
335
|
-
"sample deviation": "0.04"
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
"test name": "1,000,000 unshift",
|
|
339
|
-
"time taken (ms)": "172.87",
|
|
340
|
-
"executions per sec": "5.78",
|
|
341
|
-
"sample deviation": "0.01"
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
"test name": "1,000,000 unshift & shift",
|
|
345
|
-
"time taken (ms)": "151.32",
|
|
346
|
-
"executions per sec": "6.61",
|
|
347
|
-
"sample deviation": "0.01"
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
"test name": "1,000,000 addBefore",
|
|
351
|
-
"time taken (ms)": "262.75",
|
|
352
|
-
"executions per sec": "3.81",
|
|
353
|
-
"sample deviation": "0.07"
|
|
354
|
-
}
|
|
355
|
-
],
|
|
356
|
-
"testName": "doubly-linked-list"
|
|
357
|
-
},
|
|
358
|
-
"singly-linked-list": {
|
|
359
|
-
"benchmarks": [
|
|
360
|
-
{
|
|
361
|
-
"test name": "1,000,000 push & shift",
|
|
362
|
-
"time taken (ms)": "164.52",
|
|
363
|
-
"executions per sec": "6.08",
|
|
364
|
-
"sample deviation": "0.03"
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
"test name": "10,000 push & pop",
|
|
368
|
-
"time taken (ms)": "234.45",
|
|
369
|
-
"executions per sec": "4.27",
|
|
370
|
-
"sample deviation": "0.01"
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
"test name": "10,000 addBefore",
|
|
374
|
-
"time taken (ms)": "275.79",
|
|
375
|
-
"executions per sec": "3.63",
|
|
376
|
-
"sample deviation": "0.00"
|
|
377
|
-
}
|
|
378
|
-
],
|
|
379
|
-
"testName": "singly-linked-list"
|
|
380
|
-
},
|
|
381
|
-
"priority-queue": {
|
|
382
|
-
"benchmarks": [
|
|
383
|
-
{
|
|
384
|
-
"test name": "100,000 add",
|
|
385
|
-
"time taken (ms)": "30.74",
|
|
386
|
-
"executions per sec": "32.53",
|
|
387
|
-
"sample deviation": "0.00"
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
"test name": "100,000 add & poll",
|
|
391
|
-
"time taken (ms)": "88.16",
|
|
392
|
-
"executions per sec": "11.34",
|
|
393
|
-
"sample deviation": "4.14e-4"
|
|
394
|
-
}
|
|
395
|
-
],
|
|
396
|
-
"testName": "priority-queue"
|
|
397
|
-
},
|
|
398
|
-
"stack": {
|
|
399
|
-
"benchmarks": [
|
|
400
|
-
{
|
|
401
|
-
"test name": "1,000,000 push",
|
|
402
|
-
"time taken (ms)": "42.80",
|
|
403
|
-
"executions per sec": "23.37",
|
|
404
|
-
"sample deviation": "0.01"
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
"test name": "1,000,000 push & pop",
|
|
408
|
-
"time taken (ms)": "48.13",
|
|
409
|
-
"executions per sec": "20.78",
|
|
48
|
+
"time taken (ms)": "264.70",
|
|
49
|
+
"executions per sec": "3.78",
|
|
410
50
|
"sample deviation": "0.01"
|
|
411
51
|
}
|
|
412
52
|
],
|
|
413
|
-
"testName": "
|
|
53
|
+
"testName": "rb-tree"
|
|
414
54
|
}
|
|
415
55
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult,
|
|
8
|
+
import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, IterationType } from '../../types';
|
|
9
9
|
import { IBinaryTree } from '../../interfaces';
|
|
10
10
|
import { AVLTree, AVLTreeNode } from './avl-tree';
|
|
11
11
|
export declare class AVLTreeMultiMapNode<K = any, V = any, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNodeNested<K, V>> extends AVLTreeNode<K, V, NODE> {
|
|
@@ -36,16 +36,16 @@ export declare class AVLTreeMultiMapNode<K = any, V = any, NODE extends AVLTreeM
|
|
|
36
36
|
/**
|
|
37
37
|
* The only distinction between a AVLTreeMultiMap and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
|
|
38
38
|
*/
|
|
39
|
-
export declare class AVLTreeMultiMap<K = any, V = any, R =
|
|
39
|
+
export declare class AVLTreeMultiMap<K = any, V = any, R = object, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNodeNested<K, V>>, TREE extends AVLTreeMultiMap<K, V, R, NODE, TREE> = AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMapNested<K, V, R, NODE>>> extends AVLTree<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
|
|
40
40
|
/**
|
|
41
41
|
* The constructor initializes a new AVLTreeMultiMap object with optional initial elements.
|
|
42
|
-
* @param
|
|
42
|
+
* @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
|
|
43
43
|
* iterable object that can contain either keys, nodes, entries, or raw elements.
|
|
44
44
|
* @param [options] - The `options` parameter is an optional object that can be used to customize the
|
|
45
45
|
* behavior of the AVLTreeMultiMap. It can include properties such as `compareKeys` and
|
|
46
46
|
* `compareValues` functions to define custom comparison logic for keys and values, respectively.
|
|
47
47
|
*/
|
|
48
|
-
constructor(
|
|
48
|
+
constructor(keysNodesEntriesOrRaws?: Iterable<R | BTNRep<K, V, NODE>>, options?: AVLTreeMultiMapOptions<K, V, R>);
|
|
49
49
|
protected _count: number;
|
|
50
50
|
/**
|
|
51
51
|
* The function calculates the sum of the count property of all nodes in a tree using depth-first
|
|
@@ -84,17 +84,17 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
|
|
|
84
84
|
createTree(options?: AVLTreeMultiMapOptions<K, V, R>): TREE;
|
|
85
85
|
/**
|
|
86
86
|
* The function checks if the input is an instance of AVLTreeMultiMapNode.
|
|
87
|
-
* @param {
|
|
88
|
-
* `
|
|
89
|
-
* @returns a boolean value indicating whether the input parameter `
|
|
87
|
+
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
|
|
88
|
+
* `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
|
|
89
|
+
* @returns a boolean value indicating whether the input parameter `keyNodeEntryOrRaw` is
|
|
90
90
|
* an instance of the `AVLTreeMultiMapNode` class.
|
|
91
91
|
*/
|
|
92
|
-
isNode(
|
|
92
|
+
isNode(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R): keyNodeEntryOrRaw is NODE;
|
|
93
93
|
/**
|
|
94
|
-
* The function `
|
|
94
|
+
* The function `keyValueNodeEntryRawToNodeAndValue` converts a key, value, entry, or raw element into
|
|
95
95
|
* a node object.
|
|
96
|
-
* @param {
|
|
97
|
-
* `
|
|
96
|
+
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
|
|
97
|
+
* `keyNodeEntryOrRaw` parameter can be of type `R` or `BTNRep<K, V, NODE>`.
|
|
98
98
|
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
|
|
99
99
|
* `override` function. It represents the value associated with the key in the data structure. If no
|
|
100
100
|
* value is provided, it will default to `undefined`.
|
|
@@ -102,16 +102,16 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
|
|
|
102
102
|
* times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
|
|
103
103
|
* @returns either a NODE object or undefined.
|
|
104
104
|
*/
|
|
105
|
-
|
|
105
|
+
keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V, count?: number): [NODE | undefined, V | undefined];
|
|
106
106
|
/**
|
|
107
107
|
* Time Complexity: O(log n)
|
|
108
108
|
* Space Complexity: O(1)
|
|
109
109
|
*
|
|
110
110
|
* The function overrides the add method of a TypeScript class to add a new node to a data structure
|
|
111
111
|
* and update the count.
|
|
112
|
-
* @param {
|
|
113
|
-
* `
|
|
114
|
-
* can also accept a value of type `
|
|
112
|
+
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
|
|
113
|
+
* `keyNodeEntryOrRaw` parameter can accept a value of type `R`, which can be any type. It
|
|
114
|
+
* can also accept a value of type `BTNRep<K, V, NODE>`, which represents a key, node,
|
|
115
115
|
* entry, or raw element
|
|
116
116
|
* @param {V} [value] - The `value` parameter represents the value associated with the key in the
|
|
117
117
|
* data structure. It is an optional parameter, so it can be omitted if not needed.
|
|
@@ -120,14 +120,14 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
|
|
|
120
120
|
* be added once. However, you can specify a different value for `count` if you want to add
|
|
121
121
|
* @returns a boolean value.
|
|
122
122
|
*/
|
|
123
|
-
add(
|
|
123
|
+
add(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V, count?: number): boolean;
|
|
124
124
|
/**
|
|
125
125
|
* Time Complexity: O(log n)
|
|
126
126
|
* Space Complexity: O(1)
|
|
127
127
|
*
|
|
128
128
|
* The function overrides the delete method in a binary tree data structure, handling deletion of
|
|
129
129
|
* nodes and maintaining balance in the tree.
|
|
130
|
-
* @param {
|
|
130
|
+
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The `predicate`
|
|
131
131
|
* parameter in the `delete` method is used to specify the condition for deleting a node from the
|
|
132
132
|
* binary tree. It can be a key, node, or entry that determines which
|
|
133
133
|
* node(s) should be deleted.
|
|
@@ -140,7 +140,7 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
|
|
|
140
140
|
* method returns an array of `BinaryTreeDeleteResult` objects, each containing information about the
|
|
141
141
|
* deleted node and whether balancing is needed in the tree.
|
|
142
142
|
*/
|
|
143
|
-
delete(
|
|
143
|
+
delete(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, ignoreCount?: boolean): BinaryTreeDeleteResult<NODE>[];
|
|
144
144
|
/**
|
|
145
145
|
* Time Complexity: O(1)
|
|
146
146
|
* Space Complexity: O(1)
|
|
@@ -176,14 +176,14 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
|
|
|
176
176
|
*
|
|
177
177
|
* The `_swapProperties` function swaps the properties (key, value, count, height) between two nodes
|
|
178
178
|
* in a binary search tree.
|
|
179
|
-
* @param {R |
|
|
179
|
+
* @param {R | BSTNOptKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents the source node
|
|
180
180
|
* that will be swapped with the `destNode`.
|
|
181
|
-
* @param {R |
|
|
181
|
+
* @param {R | BSTNOptKeyOrNode<K, NODE>} destNode - The `destNode` parameter represents the destination
|
|
182
182
|
* node where the properties will be swapped with the source node.
|
|
183
183
|
* @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
|
|
184
184
|
* If either `srcNode` or `destNode` is undefined, it returns `undefined`.
|
|
185
185
|
*/
|
|
186
|
-
protected _swapProperties(srcNode: R |
|
|
186
|
+
protected _swapProperties(srcNode: R | BSTNOptKeyOrNode<K, NODE>, destNode: R | BSTNOptKeyOrNode<K, NODE>): NODE | undefined;
|
|
187
187
|
/**
|
|
188
188
|
* Time Complexity: O(1)
|
|
189
189
|
* Space Complexity: O(1)
|