data-structure-typed 1.50.5 → 1.50.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +13 -13
  3. package/benchmark/report.html +13 -13
  4. package/benchmark/report.json +168 -144
  5. package/dist/cjs/data-structures/binary-tree/binary-tree.js +19 -19
  6. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  7. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +158 -135
  8. package/dist/cjs/data-structures/binary-tree/rb-tree.js +415 -386
  9. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  10. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +1 -0
  11. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +84 -76
  12. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  13. package/dist/mjs/data-structures/binary-tree/binary-tree.js +19 -19
  14. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +158 -135
  15. package/dist/mjs/data-structures/binary-tree/rb-tree.js +412 -386
  16. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +1 -0
  17. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +84 -76
  18. package/dist/umd/data-structure-typed.js +477 -431
  19. package/dist/umd/data-structure-typed.min.js +2 -2
  20. package/dist/umd/data-structure-typed.min.js.map +1 -1
  21. package/package.json +1 -1
  22. package/src/data-structures/binary-tree/binary-tree.ts +19 -19
  23. package/src/data-structures/binary-tree/rb-tree.ts +437 -395
  24. package/src/data-structures/binary-tree/tree-multi-map.ts +85 -82
  25. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +26 -16
  26. package/test/unit/data-structures/binary-tree/overall.test.ts +23 -21
  27. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +168 -105
  28. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +311 -192
@@ -3,15 +3,15 @@
3
3
  "benchmarks": [
4
4
  {
5
5
  "test name": "100,000 add",
6
- "time taken (ms)": "6.51",
7
- "executions per sec": "153.59",
8
- "sample deviation": "4.60e-4"
6
+ "time taken (ms)": "6.42",
7
+ "executions per sec": "155.87",
8
+ "sample deviation": "1.90e-4"
9
9
  },
10
10
  {
11
11
  "test name": "100,000 add & poll",
12
- "time taken (ms)": "31.59",
13
- "executions per sec": "31.65",
14
- "sample deviation": "8.52e-4"
12
+ "time taken (ms)": "31.50",
13
+ "executions per sec": "31.74",
14
+ "sample deviation": "8.72e-4"
15
15
  }
16
16
  ],
17
17
  "testName": "heap"
@@ -19,27 +19,51 @@
19
19
  "rb-tree": {
20
20
  "benchmarks": [
21
21
  {
22
- "test name": "100,000 add",
23
- "time taken (ms)": "85.08",
24
- "executions per sec": "11.75",
22
+ "test name": "100,000 add orderly",
23
+ "time taken (ms)": "42.46",
24
+ "executions per sec": "23.55",
25
+ "sample deviation": "0.01"
26
+ },
27
+ {
28
+ "test name": "100,000 delete orderly",
29
+ "time taken (ms)": "176.04",
30
+ "executions per sec": "5.68",
31
+ "sample deviation": "0.01"
32
+ },
33
+ {
34
+ "test name": "100,000 add randomly",
35
+ "time taken (ms)": "98.02",
36
+ "executions per sec": "10.20",
25
37
  "sample deviation": "0.00"
26
38
  },
27
39
  {
28
- "test name": "100,000 add & delete randomly",
29
- "time taken (ms)": "217.11",
30
- "executions per sec": "4.61",
31
- "sample deviation": "0.02"
40
+ "test name": "100,000 delete randomly",
41
+ "time taken (ms)": "182.58",
42
+ "executions per sec": "5.48",
43
+ "sample deviation": "0.00"
32
44
  },
33
45
  {
34
- "test name": "100,000 getNode",
35
- "time taken (ms)": "178.00",
36
- "executions per sec": "5.62",
46
+ "test name": "100,000 add orderly",
47
+ "time taken (ms)": "42.10",
48
+ "executions per sec": "23.76",
49
+ "sample deviation": "8.79e-4"
50
+ },
51
+ {
52
+ "test name": "100,000 delete randomly",
53
+ "time taken (ms)": "182.16",
54
+ "executions per sec": "5.49",
55
+ "sample deviation": "5.65e-4"
56
+ },
57
+ {
58
+ "test name": "100,000 getNode randomly",
59
+ "time taken (ms)": "180.63",
60
+ "executions per sec": "5.54",
37
61
  "sample deviation": "0.00"
38
62
  },
39
63
  {
40
64
  "test name": "100,000 add & iterator",
41
- "time taken (ms)": "116.31",
42
- "executions per sec": "8.60",
65
+ "time taken (ms)": "129.92",
66
+ "executions per sec": "7.70",
43
67
  "sample deviation": "0.00"
44
68
  }
45
69
  ],
@@ -49,21 +73,21 @@
49
73
  "benchmarks": [
50
74
  {
51
75
  "test name": "1,000,000 push",
52
- "time taken (ms)": "45.98",
53
- "executions per sec": "21.75",
76
+ "time taken (ms)": "44.33",
77
+ "executions per sec": "22.56",
54
78
  "sample deviation": "0.01"
55
79
  },
56
80
  {
57
81
  "test name": "100,000 push & shift",
58
- "time taken (ms)": "4.91",
59
- "executions per sec": "203.49",
60
- "sample deviation": "7.39e-4"
82
+ "time taken (ms)": "4.68",
83
+ "executions per sec": "213.63",
84
+ "sample deviation": "1.41e-4"
61
85
  },
62
86
  {
63
87
  "test name": "Native JS Array 100,000 push & shift",
64
- "time taken (ms)": "2321.55",
65
- "executions per sec": "0.43",
66
- "sample deviation": "0.20"
88
+ "time taken (ms)": "2633.11",
89
+ "executions per sec": "0.38",
90
+ "sample deviation": "0.44"
67
91
  }
68
92
  ],
69
93
  "testName": "queue"
@@ -72,45 +96,45 @@
72
96
  "benchmarks": [
73
97
  {
74
98
  "test name": "1,000,000 push",
75
- "time taken (ms)": "24.85",
76
- "executions per sec": "40.24",
99
+ "time taken (ms)": "24.62",
100
+ "executions per sec": "40.62",
77
101
  "sample deviation": "0.00"
78
102
  },
79
103
  {
80
104
  "test name": "1,000,000 push & pop",
81
- "time taken (ms)": "31.50",
82
- "executions per sec": "31.75",
105
+ "time taken (ms)": "30.71",
106
+ "executions per sec": "32.56",
83
107
  "sample deviation": "0.00"
84
108
  },
85
109
  {
86
110
  "test name": "1,000,000 push & shift",
87
- "time taken (ms)": "30.93",
88
- "executions per sec": "32.33",
89
- "sample deviation": "0.00"
111
+ "time taken (ms)": "31.93",
112
+ "executions per sec": "31.32",
113
+ "sample deviation": "0.01"
90
114
  },
91
115
  {
92
116
  "test name": "100,000 push & shift",
93
- "time taken (ms)": "3.28",
94
- "executions per sec": "304.69",
95
- "sample deviation": "2.35e-4"
117
+ "time taken (ms)": "3.25",
118
+ "executions per sec": "307.22",
119
+ "sample deviation": "2.74e-4"
96
120
  },
97
121
  {
98
122
  "test name": "Native JS Array 100,000 push & shift",
99
- "time taken (ms)": "2040.48",
100
- "executions per sec": "0.49",
101
- "sample deviation": "0.08"
123
+ "time taken (ms)": "2455.51",
124
+ "executions per sec": "0.41",
125
+ "sample deviation": "0.29"
102
126
  },
103
127
  {
104
128
  "test name": "100,000 unshift & shift",
105
- "time taken (ms)": "2.97",
106
- "executions per sec": "336.20",
107
- "sample deviation": "5.34e-4"
129
+ "time taken (ms)": "2.94",
130
+ "executions per sec": "340.31",
131
+ "sample deviation": "2.39e-4"
108
132
  },
109
133
  {
110
134
  "test name": "Native JS Array 100,000 unshift & shift",
111
- "time taken (ms)": "4113.19",
112
- "executions per sec": "0.24",
113
- "sample deviation": "0.25"
135
+ "time taken (ms)": "4314.20",
136
+ "executions per sec": "0.23",
137
+ "sample deviation": "0.41"
114
138
  }
115
139
  ],
116
140
  "testName": "deque"
@@ -119,57 +143,57 @@
119
143
  "benchmarks": [
120
144
  {
121
145
  "test name": "1,000,000 set",
122
- "time taken (ms)": "118.59",
123
- "executions per sec": "8.43",
124
- "sample deviation": "0.03"
146
+ "time taken (ms)": "116.60",
147
+ "executions per sec": "8.58",
148
+ "sample deviation": "0.02"
125
149
  },
126
150
  {
127
151
  "test name": "Native JS Map 1,000,000 set",
128
- "time taken (ms)": "208.83",
129
- "executions per sec": "4.79",
130
- "sample deviation": "0.02"
152
+ "time taken (ms)": "202.39",
153
+ "executions per sec": "4.94",
154
+ "sample deviation": "0.01"
131
155
  },
132
156
  {
133
157
  "test name": "Native JS Set 1,000,000 add",
134
- "time taken (ms)": "168.45",
135
- "executions per sec": "5.94",
158
+ "time taken (ms)": "167.89",
159
+ "executions per sec": "5.96",
136
160
  "sample deviation": "0.01"
137
161
  },
138
162
  {
139
163
  "test name": "1,000,000 set & get",
140
- "time taken (ms)": "120.86",
141
- "executions per sec": "8.27",
142
- "sample deviation": "0.02"
164
+ "time taken (ms)": "125.21",
165
+ "executions per sec": "7.99",
166
+ "sample deviation": "0.03"
143
167
  },
144
168
  {
145
169
  "test name": "Native JS Map 1,000,000 set & get",
146
- "time taken (ms)": "270.83",
147
- "executions per sec": "3.69",
148
- "sample deviation": "0.02"
170
+ "time taken (ms)": "272.20",
171
+ "executions per sec": "3.67",
172
+ "sample deviation": "0.03"
149
173
  },
150
174
  {
151
175
  "test name": "Native JS Set 1,000,000 add & has",
152
- "time taken (ms)": "168.79",
153
- "executions per sec": "5.92",
176
+ "time taken (ms)": "168.51",
177
+ "executions per sec": "5.93",
154
178
  "sample deviation": "0.01"
155
179
  },
156
180
  {
157
181
  "test name": "1,000,000 ObjKey set & get",
158
- "time taken (ms)": "335.67",
159
- "executions per sec": "2.98",
160
- "sample deviation": "0.05"
182
+ "time taken (ms)": "309.10",
183
+ "executions per sec": "3.24",
184
+ "sample deviation": "0.01"
161
185
  },
162
186
  {
163
187
  "test name": "Native JS Map 1,000,000 ObjKey set & get",
164
- "time taken (ms)": "302.02",
165
- "executions per sec": "3.31",
166
- "sample deviation": "0.04"
188
+ "time taken (ms)": "299.43",
189
+ "executions per sec": "3.34",
190
+ "sample deviation": "0.03"
167
191
  },
168
192
  {
169
193
  "test name": "Native JS Set 1,000,000 ObjKey add & has",
170
- "time taken (ms)": "270.81",
171
- "executions per sec": "3.69",
172
- "sample deviation": "0.04"
194
+ "time taken (ms)": "260.93",
195
+ "executions per sec": "3.83",
196
+ "sample deviation": "0.02"
173
197
  }
174
198
  ],
175
199
  "testName": "hash-map"
@@ -178,15 +202,15 @@
178
202
  "benchmarks": [
179
203
  {
180
204
  "test name": "100,000 push",
181
- "time taken (ms)": "44.86",
182
- "executions per sec": "22.29",
183
- "sample deviation": "9.69e-4"
205
+ "time taken (ms)": "43.32",
206
+ "executions per sec": "23.08",
207
+ "sample deviation": "6.16e-4"
184
208
  },
185
209
  {
186
210
  "test name": "100,000 getWords",
187
- "time taken (ms)": "85.63",
188
- "executions per sec": "11.68",
189
- "sample deviation": "0.01"
211
+ "time taken (ms)": "84.84",
212
+ "executions per sec": "11.79",
213
+ "sample deviation": "0.00"
190
214
  }
191
215
  ],
192
216
  "testName": "trie"
@@ -195,27 +219,27 @@
195
219
  "benchmarks": [
196
220
  {
197
221
  "test name": "10,000 add randomly",
198
- "time taken (ms)": "128.11",
199
- "executions per sec": "7.81",
222
+ "time taken (ms)": "129.04",
223
+ "executions per sec": "7.75",
200
224
  "sample deviation": "0.00"
201
225
  },
202
226
  {
203
227
  "test name": "10,000 get",
204
- "time taken (ms)": "52.87",
205
- "executions per sec": "18.91",
206
- "sample deviation": "6.02e-4"
228
+ "time taken (ms)": "51.31",
229
+ "executions per sec": "19.49",
230
+ "sample deviation": "5.76e-4"
207
231
  },
208
232
  {
209
233
  "test name": "10,000 add & delete randomly",
210
- "time taken (ms)": "189.76",
211
- "executions per sec": "5.27",
234
+ "time taken (ms)": "190.44",
235
+ "executions per sec": "5.25",
212
236
  "sample deviation": "0.00"
213
237
  },
214
238
  {
215
239
  "test name": "10,000 addMany",
216
- "time taken (ms)": "136.54",
217
- "executions per sec": "7.32",
218
- "sample deviation": "9.74e-4"
240
+ "time taken (ms)": "137.94",
241
+ "executions per sec": "7.25",
242
+ "sample deviation": "0.00"
219
243
  }
220
244
  ],
221
245
  "testName": "avl-tree"
@@ -224,39 +248,39 @@
224
248
  "benchmarks": [
225
249
  {
226
250
  "test name": "10,000 RBTree add",
227
- "time taken (ms)": "7.00",
228
- "executions per sec": "142.81",
229
- "sample deviation": "9.38e-5"
251
+ "time taken (ms)": "8.13",
252
+ "executions per sec": "122.97",
253
+ "sample deviation": "1.87e-4"
230
254
  },
231
255
  {
232
256
  "test name": "10,000 RBTree add & delete randomly",
233
- "time taken (ms)": "16.85",
234
- "executions per sec": "59.34",
235
- "sample deviation": "1.65e-4"
257
+ "time taken (ms)": "58.30",
258
+ "executions per sec": "17.15",
259
+ "sample deviation": "5.24e-4"
236
260
  },
237
261
  {
238
262
  "test name": "10,000 RBTree get",
239
- "time taken (ms)": "18.20",
240
- "executions per sec": "54.93",
241
- "sample deviation": "1.45e-4"
263
+ "time taken (ms)": "18.16",
264
+ "executions per sec": "55.06",
265
+ "sample deviation": "2.06e-4"
242
266
  },
243
267
  {
244
268
  "test name": "10,000 AVLTree add",
245
- "time taken (ms)": "127.56",
246
- "executions per sec": "7.84",
269
+ "time taken (ms)": "129.10",
270
+ "executions per sec": "7.75",
247
271
  "sample deviation": "0.00"
248
272
  },
249
273
  {
250
274
  "test name": "10,000 AVLTree get",
251
- "time taken (ms)": "53.38",
252
- "executions per sec": "18.73",
253
- "sample deviation": "7.89e-4"
275
+ "time taken (ms)": "51.37",
276
+ "executions per sec": "19.47",
277
+ "sample deviation": "7.26e-4"
254
278
  },
255
279
  {
256
280
  "test name": "10,000 AVLTree add & delete randomly",
257
- "time taken (ms)": "190.11",
258
- "executions per sec": "5.26",
259
- "sample deviation": "0.00"
281
+ "time taken (ms)": "189.84",
282
+ "executions per sec": "5.27",
283
+ "sample deviation": "8.96e-4"
260
284
  }
261
285
  ],
262
286
  "testName": "binary-tree-overall"
@@ -266,37 +290,37 @@
266
290
  {
267
291
  "test name": "1,000 addVertex",
268
292
  "time taken (ms)": "0.10",
269
- "executions per sec": "9828.43",
270
- "sample deviation": "2.34e-6"
293
+ "executions per sec": "9882.73",
294
+ "sample deviation": "1.12e-6"
271
295
  },
272
296
  {
273
297
  "test name": "1,000 addEdge",
274
- "time taken (ms)": "6.14",
275
- "executions per sec": "162.81",
276
- "sample deviation": "1.71e-4"
298
+ "time taken (ms)": "6.18",
299
+ "executions per sec": "161.76",
300
+ "sample deviation": "7.54e-4"
277
301
  },
278
302
  {
279
303
  "test name": "1,000 getVertex",
280
304
  "time taken (ms)": "0.05",
281
305
  "executions per sec": "2.17e+4",
282
- "sample deviation": "4.30e-7"
306
+ "sample deviation": "3.35e-7"
283
307
  },
284
308
  {
285
309
  "test name": "1,000 getEdge",
286
- "time taken (ms)": "23.02",
287
- "executions per sec": "43.44",
310
+ "time taken (ms)": "23.36",
311
+ "executions per sec": "42.81",
288
312
  "sample deviation": "0.00"
289
313
  },
290
314
  {
291
315
  "test name": "tarjan",
292
- "time taken (ms)": "202.41",
293
- "executions per sec": "4.94",
316
+ "time taken (ms)": "208.84",
317
+ "executions per sec": "4.79",
294
318
  "sample deviation": "0.01"
295
319
  },
296
320
  {
297
321
  "test name": "topologicalSort",
298
- "time taken (ms)": "180.32",
299
- "executions per sec": "5.55",
322
+ "time taken (ms)": "178.78",
323
+ "executions per sec": "5.59",
300
324
  "sample deviation": "0.00"
301
325
  }
302
326
  ],
@@ -306,27 +330,27 @@
306
330
  "benchmarks": [
307
331
  {
308
332
  "test name": "1,000,000 push",
309
- "time taken (ms)": "209.36",
310
- "executions per sec": "4.78",
311
- "sample deviation": "0.04"
333
+ "time taken (ms)": "217.73",
334
+ "executions per sec": "4.59",
335
+ "sample deviation": "0.05"
312
336
  },
313
337
  {
314
338
  "test name": "1,000,000 unshift",
315
- "time taken (ms)": "217.02",
316
- "executions per sec": "4.61",
317
- "sample deviation": "0.08"
339
+ "time taken (ms)": "200.41",
340
+ "executions per sec": "4.99",
341
+ "sample deviation": "0.04"
318
342
  },
319
343
  {
320
344
  "test name": "1,000,000 unshift & shift",
321
- "time taken (ms)": "174.28",
322
- "executions per sec": "5.74",
323
- "sample deviation": "0.05"
345
+ "time taken (ms)": "168.75",
346
+ "executions per sec": "5.93",
347
+ "sample deviation": "0.04"
324
348
  },
325
349
  {
326
350
  "test name": "1,000,000 addBefore",
327
- "time taken (ms)": "331.23",
328
- "executions per sec": "3.02",
329
- "sample deviation": "0.08"
351
+ "time taken (ms)": "298.21",
352
+ "executions per sec": "3.35",
353
+ "sample deviation": "0.06"
330
354
  }
331
355
  ],
332
356
  "testName": "doubly-linked-list"
@@ -335,20 +359,20 @@
335
359
  "benchmarks": [
336
360
  {
337
361
  "test name": "1,000,000 push & shift",
338
- "time taken (ms)": "217.34",
339
- "executions per sec": "4.60",
340
- "sample deviation": "0.07"
362
+ "time taken (ms)": "196.65",
363
+ "executions per sec": "5.09",
364
+ "sample deviation": "0.04"
341
365
  },
342
366
  {
343
367
  "test name": "10,000 push & pop",
344
- "time taken (ms)": "216.54",
345
- "executions per sec": "4.62",
346
- "sample deviation": "0.01"
368
+ "time taken (ms)": "221.63",
369
+ "executions per sec": "4.51",
370
+ "sample deviation": "0.02"
347
371
  },
348
372
  {
349
373
  "test name": "10,000 addBefore",
350
- "time taken (ms)": "247.69",
351
- "executions per sec": "4.04",
374
+ "time taken (ms)": "249.40",
375
+ "executions per sec": "4.01",
352
376
  "sample deviation": "0.01"
353
377
  }
354
378
  ],
@@ -358,15 +382,15 @@
358
382
  "benchmarks": [
359
383
  {
360
384
  "test name": "100,000 add",
361
- "time taken (ms)": "27.82",
362
- "executions per sec": "35.94",
385
+ "time taken (ms)": "28.95",
386
+ "executions per sec": "34.55",
363
387
  "sample deviation": "0.00"
364
388
  },
365
389
  {
366
390
  "test name": "100,000 add & poll",
367
- "time taken (ms)": "78.76",
368
- "executions per sec": "12.70",
369
- "sample deviation": "0.02"
391
+ "time taken (ms)": "76.25",
392
+ "executions per sec": "13.11",
393
+ "sample deviation": "6.57e-4"
370
394
  }
371
395
  ],
372
396
  "testName": "priority-queue"
@@ -375,14 +399,14 @@
375
399
  "benchmarks": [
376
400
  {
377
401
  "test name": "1,000,000 push",
378
- "time taken (ms)": "40.75",
379
- "executions per sec": "24.54",
402
+ "time taken (ms)": "39.72",
403
+ "executions per sec": "25.18",
380
404
  "sample deviation": "0.01"
381
405
  },
382
406
  {
383
407
  "test name": "1,000,000 push & pop",
384
- "time taken (ms)": "48.07",
385
- "executions per sec": "20.80",
408
+ "time taken (ms)": "49.18",
409
+ "executions per sec": "20.33",
386
410
  "sample deviation": "0.01"
387
411
  }
388
412
  ],
@@ -736,7 +736,7 @@ class BinaryTree extends base_1.IterableEntryBase {
736
736
  return true;
737
737
  if (iterationType === types_1.IterationType.RECURSIVE) {
738
738
  const dfs = (cur, min, max) => {
739
- if (!cur)
739
+ if (!this.isRealNode(cur))
740
740
  return true;
741
741
  const numKey = this.extractor(cur.key);
742
742
  if (numKey <= min || numKey >= max)
@@ -753,14 +753,14 @@ class BinaryTree extends base_1.IterableEntryBase {
753
753
  let prev = checkMax ? Number.MAX_SAFE_INTEGER : Number.MIN_SAFE_INTEGER;
754
754
  // @ts-ignore
755
755
  let curr = beginRoot;
756
- while (curr || stack.length > 0) {
757
- while (curr) {
756
+ while (this.isRealNode(curr) || stack.length > 0) {
757
+ while (this.isRealNode(curr)) {
758
758
  stack.push(curr);
759
759
  curr = curr.left;
760
760
  }
761
761
  curr = stack.pop();
762
762
  const numKey = this.extractor(curr.key);
763
- if (!curr || (!checkMax && prev >= numKey) || (checkMax && prev <= numKey))
763
+ if (!this.isRealNode(curr) || (!checkMax && prev >= numKey) || (checkMax && prev <= numKey))
764
764
  return false;
765
765
  prev = numKey;
766
766
  curr = curr.right;
@@ -825,7 +825,7 @@ class BinaryTree extends base_1.IterableEntryBase {
825
825
  return -1;
826
826
  if (iterationType === types_1.IterationType.RECURSIVE) {
827
827
  const _getMaxHeight = (cur) => {
828
- if (!cur)
828
+ if (!this.isRealNode(cur))
829
829
  return -1;
830
830
  const leftHeight = _getMaxHeight(cur.left);
831
831
  const rightHeight = _getMaxHeight(cur.right);
@@ -838,9 +838,9 @@ class BinaryTree extends base_1.IterableEntryBase {
838
838
  let maxHeight = 0;
839
839
  while (stack.length > 0) {
840
840
  const { node, depth } = stack.pop();
841
- if (node.left)
841
+ if (this.isRealNode(node.left))
842
842
  stack.push({ node: node.left, depth: depth + 1 });
843
- if (node.right)
843
+ if (this.isRealNode(node.right))
844
844
  stack.push({ node: node.right, depth: depth + 1 });
845
845
  maxHeight = Math.max(maxHeight, depth);
846
846
  }
@@ -1117,48 +1117,48 @@ class BinaryTree extends base_1.IterableEntryBase {
1117
1117
  switch (pattern) {
1118
1118
  case 'in':
1119
1119
  if (includeNull) {
1120
- if (node && this.isNodeOrNull(node.left))
1120
+ if (this.isRealNode(node) && this.isNodeOrNull(node.left))
1121
1121
  _traverse(node.left);
1122
1122
  this.isNodeOrNull(node) && ans.push(callback(node));
1123
- if (node && this.isNodeOrNull(node.right))
1123
+ if (this.isRealNode(node) && this.isNodeOrNull(node.right))
1124
1124
  _traverse(node.right);
1125
1125
  }
1126
1126
  else {
1127
- if (node && node.left)
1127
+ if (this.isRealNode(node) && this.isRealNode(node.left))
1128
1128
  _traverse(node.left);
1129
1129
  this.isRealNode(node) && ans.push(callback(node));
1130
- if (node && node.right)
1130
+ if (this.isRealNode(node) && this.isRealNode(node.right))
1131
1131
  _traverse(node.right);
1132
1132
  }
1133
1133
  break;
1134
1134
  case 'pre':
1135
1135
  if (includeNull) {
1136
1136
  this.isNodeOrNull(node) && ans.push(callback(node));
1137
- if (node && this.isNodeOrNull(node.left))
1137
+ if (this.isRealNode(node) && this.isNodeOrNull(node.left))
1138
1138
  _traverse(node.left);
1139
- if (node && this.isNodeOrNull(node.right))
1139
+ if (this.isRealNode(node) && this.isNodeOrNull(node.right))
1140
1140
  _traverse(node.right);
1141
1141
  }
1142
1142
  else {
1143
1143
  this.isRealNode(node) && ans.push(callback(node));
1144
- if (node && node.left)
1144
+ if (this.isRealNode(node) && this.isRealNode(node.left))
1145
1145
  _traverse(node.left);
1146
- if (node && node.right)
1146
+ if (this.isRealNode(node) && this.isRealNode(node.right))
1147
1147
  _traverse(node.right);
1148
1148
  }
1149
1149
  break;
1150
1150
  case 'post':
1151
1151
  if (includeNull) {
1152
- if (node && this.isNodeOrNull(node.left))
1152
+ if (this.isRealNode(node) && this.isNodeOrNull(node.left))
1153
1153
  _traverse(node.left);
1154
- if (node && this.isNodeOrNull(node.right))
1154
+ if (this.isRealNode(node) && this.isNodeOrNull(node.right))
1155
1155
  _traverse(node.right);
1156
1156
  this.isNodeOrNull(node) && ans.push(callback(node));
1157
1157
  }
1158
1158
  else {
1159
- if (node && node.left)
1159
+ if (this.isRealNode(node) && this.isRealNode(node.left))
1160
1160
  _traverse(node.left);
1161
- if (node && node.right)
1161
+ if (this.isRealNode(node) && this.isRealNode(node.right))
1162
1162
  _traverse(node.right);
1163
1163
  this.isRealNode(node) && ans.push(callback(node));
1164
1164
  }