data-structure-typed 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -1
- package/README.md +11 -11
- package/benchmark/report.html +10 -10
- package/benchmark/report.json +135 -135
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +14 -10
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +1 -1
- package/dist/cjs/data-structures/queue/queue.js +1 -1
- package/dist/cjs/types/utils/utils.d.ts +5 -6
- package/dist/cjs/utils/utils.d.ts +110 -49
- package/dist/cjs/utils/utils.js +147 -73
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/binary-tree.js +15 -11
- package/dist/esm/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/esm/data-structures/queue/queue.d.ts +1 -1
- package/dist/esm/data-structures/queue/queue.js +1 -1
- package/dist/esm/types/utils/utils.d.ts +5 -6
- package/dist/esm/utils/utils.d.ts +110 -49
- package/dist/esm/utils/utils.js +138 -68
- package/dist/esm/utils/utils.js.map +1 -1
- package/dist/umd/data-structure-typed.js +53 -49
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +8 -1
- package/src/data-structures/binary-tree/binary-tree.ts +18 -13
- package/src/types/utils/utils.ts +7 -5
- package/src/utils/utils.ts +157 -86
- package/test/unit/data-structures/binary-tree/bst.test.ts +76 -0
package/benchmark/report.json
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
"benchmarks": [
|
|
4
4
|
{
|
|
5
5
|
"test name": "100,000 add",
|
|
6
|
-
"time taken (ms)": "
|
|
7
|
-
"sample mean (secs)": "0.
|
|
8
|
-
"sample deviation": "1.
|
|
6
|
+
"time taken (ms)": "3.01",
|
|
7
|
+
"sample mean (secs)": "0.00",
|
|
8
|
+
"sample deviation": "1.05e-4"
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"test name": "100,000 add & poll",
|
|
12
|
-
"time taken (ms)": "
|
|
13
|
-
"sample mean (secs)": "0.
|
|
14
|
-
"sample deviation": "
|
|
12
|
+
"time taken (ms)": "16.57",
|
|
13
|
+
"sample mean (secs)": "0.02",
|
|
14
|
+
"sample deviation": "4.12e-4"
|
|
15
15
|
}
|
|
16
16
|
],
|
|
17
17
|
"testName": "heap"
|
|
@@ -20,45 +20,45 @@
|
|
|
20
20
|
"benchmarks": [
|
|
21
21
|
{
|
|
22
22
|
"test name": "100,000 add randomly",
|
|
23
|
-
"time taken (ms)": "
|
|
24
|
-
"sample mean (secs)": "0.
|
|
25
|
-
"sample deviation": "0.
|
|
23
|
+
"time taken (ms)": "276.06",
|
|
24
|
+
"sample mean (secs)": "0.28",
|
|
25
|
+
"sample deviation": "0.00"
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
"test name": "100,000 add",
|
|
29
|
-
"time taken (ms)": "
|
|
30
|
-
"sample mean (secs)": "0.
|
|
31
|
-
"sample deviation": "0.
|
|
29
|
+
"time taken (ms)": "247.11",
|
|
30
|
+
"sample mean (secs)": "0.25",
|
|
31
|
+
"sample deviation": "0.01"
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
"test name": "100,000 get",
|
|
35
|
-
"time taken (ms)": "0.
|
|
36
|
-
"sample mean (secs)": "
|
|
37
|
-
"sample deviation": "
|
|
35
|
+
"time taken (ms)": "0.28",
|
|
36
|
+
"sample mean (secs)": "2.82e-4",
|
|
37
|
+
"sample deviation": "9.27e-5"
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
"test name": "100,000 getNode",
|
|
41
|
-
"time taken (ms)": "
|
|
42
|
-
"sample mean (secs)": "0.
|
|
43
|
-
"sample deviation": "0.
|
|
41
|
+
"time taken (ms)": "168.47",
|
|
42
|
+
"sample mean (secs)": "0.17",
|
|
43
|
+
"sample deviation": "0.01"
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
"test name": "100,000 iterator",
|
|
47
|
-
"time taken (ms)": "
|
|
48
|
-
"sample mean (secs)": "0.
|
|
47
|
+
"time taken (ms)": "12.84",
|
|
48
|
+
"sample mean (secs)": "0.01",
|
|
49
49
|
"sample deviation": "0.00"
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
"test name": "100,000 add & delete orderly",
|
|
53
|
-
"time taken (ms)": "
|
|
54
|
-
"sample mean (secs)": "0.
|
|
55
|
-
"sample deviation": "0.
|
|
53
|
+
"time taken (ms)": "385.64",
|
|
54
|
+
"sample mean (secs)": "0.39",
|
|
55
|
+
"sample deviation": "0.00"
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"test name": "100,000 add & delete randomly",
|
|
59
|
-
"time taken (ms)": "
|
|
60
|
-
"sample mean (secs)": "0.
|
|
61
|
-
"sample deviation": "0.
|
|
59
|
+
"time taken (ms)": "501.31",
|
|
60
|
+
"sample mean (secs)": "0.50",
|
|
61
|
+
"sample deviation": "0.01"
|
|
62
62
|
}
|
|
63
63
|
],
|
|
64
64
|
"testName": "avl-tree"
|
|
@@ -67,57 +67,57 @@
|
|
|
67
67
|
"benchmarks": [
|
|
68
68
|
{
|
|
69
69
|
"test name": "100,000 add randomly",
|
|
70
|
-
"time taken (ms)": "
|
|
71
|
-
"sample mean (secs)": "0.
|
|
70
|
+
"time taken (ms)": "78.51",
|
|
71
|
+
"sample mean (secs)": "0.08",
|
|
72
72
|
"sample deviation": "0.00"
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
"test name": "100,000 add",
|
|
76
|
-
"time taken (ms)": "
|
|
77
|
-
"sample mean (secs)": "0.
|
|
78
|
-
"sample deviation": "
|
|
76
|
+
"time taken (ms)": "104.83",
|
|
77
|
+
"sample mean (secs)": "0.10",
|
|
78
|
+
"sample deviation": "0.00"
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
"test name": "100,000 get",
|
|
82
|
-
"time taken (ms)": "
|
|
83
|
-
"sample mean (secs)": "
|
|
84
|
-
"sample deviation": "
|
|
82
|
+
"time taken (ms)": "0.53",
|
|
83
|
+
"sample mean (secs)": "5.26e-4",
|
|
84
|
+
"sample deviation": "7.38e-5"
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
87
|
"test name": "100,000 getNode",
|
|
88
|
-
"time taken (ms)": "
|
|
89
|
-
"sample mean (secs)": "0.
|
|
90
|
-
"sample deviation": "0.
|
|
88
|
+
"time taken (ms)": "249.02",
|
|
89
|
+
"sample mean (secs)": "0.25",
|
|
90
|
+
"sample deviation": "0.01"
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
"test name": "100,000 node mode add randomly",
|
|
94
|
-
"time taken (ms)": "
|
|
95
|
-
"sample mean (secs)": "0.
|
|
94
|
+
"time taken (ms)": "77.15",
|
|
95
|
+
"sample mean (secs)": "0.08",
|
|
96
96
|
"sample deviation": "0.00"
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
"test name": "100,000 node mode get",
|
|
100
|
-
"time taken (ms)": "
|
|
101
|
-
"sample mean (secs)": "0.
|
|
102
|
-
"sample deviation": "0.
|
|
100
|
+
"time taken (ms)": "253.61",
|
|
101
|
+
"sample mean (secs)": "0.25",
|
|
102
|
+
"sample deviation": "0.01"
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
"test name": "100,000 iterator",
|
|
106
|
-
"time taken (ms)": "
|
|
107
|
-
"sample mean (secs)": "0.
|
|
106
|
+
"time taken (ms)": "13.23",
|
|
107
|
+
"sample mean (secs)": "0.01",
|
|
108
108
|
"sample deviation": "0.00"
|
|
109
109
|
},
|
|
110
110
|
{
|
|
111
111
|
"test name": "100,000 add & delete orderly",
|
|
112
|
-
"time taken (ms)": "
|
|
113
|
-
"sample mean (secs)": "0.
|
|
112
|
+
"time taken (ms)": "226.81",
|
|
113
|
+
"sample mean (secs)": "0.23",
|
|
114
114
|
"sample deviation": "0.00"
|
|
115
115
|
},
|
|
116
116
|
{
|
|
117
117
|
"test name": "100,000 add & delete randomly",
|
|
118
|
-
"time taken (ms)": "
|
|
119
|
-
"sample mean (secs)": "0.
|
|
120
|
-
"sample deviation": "0.
|
|
118
|
+
"time taken (ms)": "325.56",
|
|
119
|
+
"sample mean (secs)": "0.33",
|
|
120
|
+
"sample deviation": "0.00"
|
|
121
121
|
}
|
|
122
122
|
],
|
|
123
123
|
"testName": "red-black-tree"
|
|
@@ -126,26 +126,26 @@
|
|
|
126
126
|
"benchmarks": [
|
|
127
127
|
{
|
|
128
128
|
"test name": "1,000,000 push",
|
|
129
|
-
"time taken (ms)": "
|
|
130
|
-
"sample mean (secs)": "0.
|
|
129
|
+
"time taken (ms)": "109.12",
|
|
130
|
+
"sample mean (secs)": "0.11",
|
|
131
131
|
"sample deviation": "0.02"
|
|
132
132
|
},
|
|
133
133
|
{
|
|
134
134
|
"test name": "1,000,000 unshift",
|
|
135
|
-
"time taken (ms)": "
|
|
136
|
-
"sample mean (secs)": "0.
|
|
137
|
-
"sample deviation": "0.
|
|
135
|
+
"time taken (ms)": "105.65",
|
|
136
|
+
"sample mean (secs)": "0.11",
|
|
137
|
+
"sample deviation": "0.01"
|
|
138
138
|
},
|
|
139
139
|
{
|
|
140
140
|
"test name": "1,000,000 unshift & shift",
|
|
141
|
-
"time taken (ms)": "
|
|
142
|
-
"sample mean (secs)": "0.
|
|
143
|
-
"sample deviation": "0.
|
|
141
|
+
"time taken (ms)": "96.20",
|
|
142
|
+
"sample mean (secs)": "0.10",
|
|
143
|
+
"sample deviation": "0.01"
|
|
144
144
|
},
|
|
145
145
|
{
|
|
146
146
|
"test name": "1,000,000 addBefore",
|
|
147
|
-
"time taken (ms)": "
|
|
148
|
-
"sample mean (secs)": "0.
|
|
147
|
+
"time taken (ms)": "157.94",
|
|
148
|
+
"sample mean (secs)": "0.16",
|
|
149
149
|
"sample deviation": "0.03"
|
|
150
150
|
}
|
|
151
151
|
],
|
|
@@ -155,38 +155,38 @@
|
|
|
155
155
|
"benchmarks": [
|
|
156
156
|
{
|
|
157
157
|
"test name": "1,000 addVertex",
|
|
158
|
-
"time taken (ms)": "0.
|
|
159
|
-
"sample mean (secs)": "
|
|
160
|
-
"sample deviation": "
|
|
158
|
+
"time taken (ms)": "0.05",
|
|
159
|
+
"sample mean (secs)": "4.73e-5",
|
|
160
|
+
"sample deviation": "1.24e-6"
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
"test name": "1,000 addEdge",
|
|
164
|
-
"time taken (ms)": "
|
|
165
|
-
"sample mean (secs)": "0.
|
|
166
|
-
"sample deviation": "
|
|
164
|
+
"time taken (ms)": "2.96",
|
|
165
|
+
"sample mean (secs)": "0.00",
|
|
166
|
+
"sample deviation": "9.68e-5"
|
|
167
167
|
},
|
|
168
168
|
{
|
|
169
169
|
"test name": "1,000 getVertex",
|
|
170
|
-
"time taken (ms)": "0.
|
|
171
|
-
"sample mean (secs)": "
|
|
172
|
-
"sample deviation": "1.
|
|
170
|
+
"time taken (ms)": "0.05",
|
|
171
|
+
"sample mean (secs)": "4.70e-5",
|
|
172
|
+
"sample deviation": "1.27e-6"
|
|
173
173
|
},
|
|
174
174
|
{
|
|
175
175
|
"test name": "1,000 getEdge",
|
|
176
|
-
"time taken (ms)": "
|
|
177
|
-
"sample mean (secs)": "0.
|
|
178
|
-
"sample deviation": "0.
|
|
176
|
+
"time taken (ms)": "44.92",
|
|
177
|
+
"sample mean (secs)": "0.04",
|
|
178
|
+
"sample deviation": "0.01"
|
|
179
179
|
},
|
|
180
180
|
{
|
|
181
181
|
"test name": "tarjan",
|
|
182
|
-
"time taken (ms)": "
|
|
183
|
-
"sample mean (secs)": "0.
|
|
184
|
-
"sample deviation": "0.
|
|
182
|
+
"time taken (ms)": "257.57",
|
|
183
|
+
"sample mean (secs)": "0.26",
|
|
184
|
+
"sample deviation": "0.02"
|
|
185
185
|
},
|
|
186
186
|
{
|
|
187
187
|
"test name": "topologicalSort",
|
|
188
|
-
"time taken (ms)": "
|
|
189
|
-
"sample mean (secs)": "0.
|
|
188
|
+
"time taken (ms)": "207.12",
|
|
189
|
+
"sample mean (secs)": "0.21",
|
|
190
190
|
"sample deviation": "0.01"
|
|
191
191
|
}
|
|
192
192
|
],
|
|
@@ -196,21 +196,21 @@
|
|
|
196
196
|
"benchmarks": [
|
|
197
197
|
{
|
|
198
198
|
"test name": "1,000,000 push",
|
|
199
|
-
"time taken (ms)": "
|
|
200
|
-
"sample mean (secs)": "0.
|
|
201
|
-
"sample deviation": "0.
|
|
199
|
+
"time taken (ms)": "25.86",
|
|
200
|
+
"sample mean (secs)": "0.03",
|
|
201
|
+
"sample deviation": "0.01"
|
|
202
202
|
},
|
|
203
203
|
{
|
|
204
204
|
"test name": "100,000 push & shift",
|
|
205
|
-
"time taken (ms)": "
|
|
206
|
-
"sample mean (secs)": "0.
|
|
205
|
+
"time taken (ms)": "2.52",
|
|
206
|
+
"sample mean (secs)": "0.00",
|
|
207
207
|
"sample deviation": "0.00"
|
|
208
208
|
},
|
|
209
209
|
{
|
|
210
210
|
"test name": "Native JS Array 100,000 push & shift",
|
|
211
|
-
"time taken (ms)": "
|
|
212
|
-
"sample mean (secs)": "
|
|
213
|
-
"sample deviation": "0.
|
|
211
|
+
"time taken (ms)": "902.25",
|
|
212
|
+
"sample mean (secs)": "0.90",
|
|
213
|
+
"sample deviation": "0.00"
|
|
214
214
|
}
|
|
215
215
|
],
|
|
216
216
|
"testName": "queue"
|
|
@@ -219,45 +219,45 @@
|
|
|
219
219
|
"benchmarks": [
|
|
220
220
|
{
|
|
221
221
|
"test name": "1,000,000 push",
|
|
222
|
-
"time taken (ms)": "
|
|
223
|
-
"sample mean (secs)": "0.
|
|
224
|
-
"sample deviation": "0.
|
|
222
|
+
"time taken (ms)": "10.14",
|
|
223
|
+
"sample mean (secs)": "0.01",
|
|
224
|
+
"sample deviation": "0.00"
|
|
225
225
|
},
|
|
226
226
|
{
|
|
227
227
|
"test name": "1,000,000 push & pop",
|
|
228
|
-
"time taken (ms)": "
|
|
229
|
-
"sample mean (secs)": "0.
|
|
228
|
+
"time taken (ms)": "14.13",
|
|
229
|
+
"sample mean (secs)": "0.01",
|
|
230
230
|
"sample deviation": "0.01"
|
|
231
231
|
},
|
|
232
232
|
{
|
|
233
233
|
"test name": "1,000,000 push & shift",
|
|
234
|
-
"time taken (ms)": "
|
|
235
|
-
"sample mean (secs)": "0.
|
|
234
|
+
"time taken (ms)": "13.35",
|
|
235
|
+
"sample mean (secs)": "0.01",
|
|
236
236
|
"sample deviation": "0.01"
|
|
237
237
|
},
|
|
238
238
|
{
|
|
239
239
|
"test name": "100,000 push & shift",
|
|
240
|
-
"time taken (ms)": "
|
|
240
|
+
"time taken (ms)": "1.34",
|
|
241
241
|
"sample mean (secs)": "0.00",
|
|
242
|
-
"sample deviation": "
|
|
242
|
+
"sample deviation": "6.86e-4"
|
|
243
243
|
},
|
|
244
244
|
{
|
|
245
245
|
"test name": "Native JS Array 100,000 push & shift",
|
|
246
|
-
"time taken (ms)": "
|
|
247
|
-
"sample mean (secs)": "
|
|
248
|
-
"sample deviation": "0.
|
|
246
|
+
"time taken (ms)": "904.80",
|
|
247
|
+
"sample mean (secs)": "0.90",
|
|
248
|
+
"sample deviation": "0.01"
|
|
249
249
|
},
|
|
250
250
|
{
|
|
251
251
|
"test name": "100,000 unshift & shift",
|
|
252
|
-
"time taken (ms)": "
|
|
252
|
+
"time taken (ms)": "1.21",
|
|
253
253
|
"sample mean (secs)": "0.00",
|
|
254
|
-
"sample deviation": "
|
|
254
|
+
"sample deviation": "5.28e-4"
|
|
255
255
|
},
|
|
256
256
|
{
|
|
257
257
|
"test name": "Native JS Array 100,000 unshift & shift",
|
|
258
|
-
"time taken (ms)": "
|
|
259
|
-
"sample mean (secs)": "
|
|
260
|
-
"sample deviation": "0.
|
|
258
|
+
"time taken (ms)": "1801.73",
|
|
259
|
+
"sample mean (secs)": "1.80",
|
|
260
|
+
"sample deviation": "0.01"
|
|
261
261
|
}
|
|
262
262
|
],
|
|
263
263
|
"testName": "deque"
|
|
@@ -266,57 +266,57 @@
|
|
|
266
266
|
"benchmarks": [
|
|
267
267
|
{
|
|
268
268
|
"test name": "1,000,000 set",
|
|
269
|
-
"time taken (ms)": "
|
|
270
|
-
"sample mean (secs)": "0.
|
|
271
|
-
"sample deviation": "0.
|
|
269
|
+
"time taken (ms)": "48.91",
|
|
270
|
+
"sample mean (secs)": "0.05",
|
|
271
|
+
"sample deviation": "0.02"
|
|
272
272
|
},
|
|
273
273
|
{
|
|
274
274
|
"test name": "Native JS Map 1,000,000 set",
|
|
275
|
-
"time taken (ms)": "
|
|
276
|
-
"sample mean (secs)": "0.
|
|
277
|
-
"sample deviation": "0.
|
|
275
|
+
"time taken (ms)": "141.21",
|
|
276
|
+
"sample mean (secs)": "0.14",
|
|
277
|
+
"sample deviation": "0.02"
|
|
278
278
|
},
|
|
279
279
|
{
|
|
280
280
|
"test name": "Native JS Set 1,000,000 add",
|
|
281
|
-
"time taken (ms)": "
|
|
282
|
-
"sample mean (secs)": "0.
|
|
283
|
-
"sample deviation": "0.
|
|
281
|
+
"time taken (ms)": "116.73",
|
|
282
|
+
"sample mean (secs)": "0.12",
|
|
283
|
+
"sample deviation": "0.03"
|
|
284
284
|
},
|
|
285
285
|
{
|
|
286
286
|
"test name": "1,000,000 set & get",
|
|
287
|
-
"time taken (ms)": "
|
|
288
|
-
"sample mean (secs)": "0.
|
|
289
|
-
"sample deviation": "0.
|
|
287
|
+
"time taken (ms)": "40.73",
|
|
288
|
+
"sample mean (secs)": "0.04",
|
|
289
|
+
"sample deviation": "0.01"
|
|
290
290
|
},
|
|
291
291
|
{
|
|
292
292
|
"test name": "Native JS Map 1,000,000 set & get",
|
|
293
|
-
"time taken (ms)": "
|
|
294
|
-
"sample mean (secs)": "0.
|
|
293
|
+
"time taken (ms)": "196.24",
|
|
294
|
+
"sample mean (secs)": "0.20",
|
|
295
295
|
"sample deviation": "0.02"
|
|
296
296
|
},
|
|
297
297
|
{
|
|
298
298
|
"test name": "Native JS Set 1,000,000 add & has",
|
|
299
|
-
"time taken (ms)": "
|
|
300
|
-
"sample mean (secs)": "0.
|
|
299
|
+
"time taken (ms)": "158.72",
|
|
300
|
+
"sample mean (secs)": "0.16",
|
|
301
301
|
"sample deviation": "0.02"
|
|
302
302
|
},
|
|
303
303
|
{
|
|
304
304
|
"test name": "1,000,000 ObjKey set & get",
|
|
305
|
-
"time taken (ms)": "
|
|
306
|
-
"sample mean (secs)": "0.
|
|
307
|
-
"sample deviation": "0.
|
|
305
|
+
"time taken (ms)": "242.77",
|
|
306
|
+
"sample mean (secs)": "0.24",
|
|
307
|
+
"sample deviation": "0.08"
|
|
308
308
|
},
|
|
309
309
|
{
|
|
310
310
|
"test name": "Native JS Map 1,000,000 ObjKey set & get",
|
|
311
|
-
"time taken (ms)": "
|
|
312
|
-
"sample mean (secs)": "0.
|
|
313
|
-
"sample deviation": "0.
|
|
311
|
+
"time taken (ms)": "231.61",
|
|
312
|
+
"sample mean (secs)": "0.23",
|
|
313
|
+
"sample deviation": "0.09"
|
|
314
314
|
},
|
|
315
315
|
{
|
|
316
316
|
"test name": "Native JS Set 1,000,000 ObjKey add & has",
|
|
317
|
-
"time taken (ms)": "
|
|
318
|
-
"sample mean (secs)": "0.
|
|
319
|
-
"sample deviation": "0.
|
|
317
|
+
"time taken (ms)": "177.41",
|
|
318
|
+
"sample mean (secs)": "0.18",
|
|
319
|
+
"sample deviation": "0.05"
|
|
320
320
|
}
|
|
321
321
|
],
|
|
322
322
|
"testName": "hash-map"
|
|
@@ -325,14 +325,14 @@
|
|
|
325
325
|
"benchmarks": [
|
|
326
326
|
{
|
|
327
327
|
"test name": "100,000 push",
|
|
328
|
-
"time taken (ms)": "
|
|
329
|
-
"sample mean (secs)": "0.
|
|
330
|
-
"sample deviation": "
|
|
328
|
+
"time taken (ms)": "21.20",
|
|
329
|
+
"sample mean (secs)": "0.02",
|
|
330
|
+
"sample deviation": "0.00"
|
|
331
331
|
},
|
|
332
332
|
{
|
|
333
333
|
"test name": "100,000 getWords",
|
|
334
|
-
"time taken (ms)": "
|
|
335
|
-
"sample mean (secs)": "0.
|
|
334
|
+
"time taken (ms)": "39.18",
|
|
335
|
+
"sample mean (secs)": "0.04",
|
|
336
336
|
"sample deviation": "0.00"
|
|
337
337
|
}
|
|
338
338
|
],
|
|
@@ -342,14 +342,14 @@
|
|
|
342
342
|
"benchmarks": [
|
|
343
343
|
{
|
|
344
344
|
"test name": "1,000,000 push",
|
|
345
|
-
"time taken (ms)": "
|
|
346
|
-
"sample mean (secs)": "0.
|
|
345
|
+
"time taken (ms)": "22.12",
|
|
346
|
+
"sample mean (secs)": "0.02",
|
|
347
347
|
"sample deviation": "0.01"
|
|
348
348
|
},
|
|
349
349
|
{
|
|
350
350
|
"test name": "1,000,000 push & pop",
|
|
351
|
-
"time taken (ms)": "
|
|
352
|
-
"sample mean (secs)": "0.
|
|
351
|
+
"time taken (ms)": "25.51",
|
|
352
|
+
"sample mean (secs)": "0.03",
|
|
353
353
|
"sample deviation": "0.01"
|
|
354
354
|
}
|
|
355
355
|
],
|
|
@@ -1092,18 +1092,20 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
1092
1092
|
return callback(startNode);
|
|
1093
1093
|
if (iterationType === 'RECURSIVE') {
|
|
1094
1094
|
const dfs = (cur) => {
|
|
1095
|
-
|
|
1095
|
+
const { left } = cur;
|
|
1096
|
+
if (!this.isRealNode(left))
|
|
1096
1097
|
return cur;
|
|
1097
|
-
return dfs(
|
|
1098
|
+
return dfs(left);
|
|
1098
1099
|
};
|
|
1099
1100
|
return callback(dfs(startNode));
|
|
1100
1101
|
}
|
|
1101
1102
|
else {
|
|
1102
1103
|
// Indirect implementation of iteration using tail recursion optimization
|
|
1103
|
-
const dfs = (0, utils_1.
|
|
1104
|
-
|
|
1104
|
+
const dfs = (0, utils_1.makeTrampoline)((cur) => {
|
|
1105
|
+
const { left } = cur;
|
|
1106
|
+
if (!this.isRealNode(left))
|
|
1105
1107
|
return cur;
|
|
1106
|
-
return
|
|
1108
|
+
return (0, utils_1.makeTrampolineThunk)(() => dfs(left));
|
|
1107
1109
|
});
|
|
1108
1110
|
return callback(dfs(startNode));
|
|
1109
1111
|
}
|
|
@@ -1138,18 +1140,20 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
1138
1140
|
return callback(startNode);
|
|
1139
1141
|
if (iterationType === 'RECURSIVE') {
|
|
1140
1142
|
const dfs = (cur) => {
|
|
1141
|
-
|
|
1143
|
+
const { right } = cur;
|
|
1144
|
+
if (!this.isRealNode(right))
|
|
1142
1145
|
return cur;
|
|
1143
|
-
return dfs(
|
|
1146
|
+
return dfs(right);
|
|
1144
1147
|
};
|
|
1145
1148
|
return callback(dfs(startNode));
|
|
1146
1149
|
}
|
|
1147
1150
|
else {
|
|
1148
1151
|
// Indirect implementation of iteration using tail recursion optimization
|
|
1149
|
-
const dfs = (0, utils_1.
|
|
1150
|
-
|
|
1152
|
+
const dfs = (0, utils_1.makeTrampoline)((cur) => {
|
|
1153
|
+
const { right } = cur;
|
|
1154
|
+
if (!this.isRealNode(right))
|
|
1151
1155
|
return cur;
|
|
1152
|
-
return
|
|
1156
|
+
return (0, utils_1.makeTrampolineThunk)(() => dfs(right));
|
|
1153
1157
|
});
|
|
1154
1158
|
return callback(dfs(startNode));
|
|
1155
1159
|
}
|