@@ -1125,22 +1125,15 @@ namespace lib_interval_tree
1125
1125
if (ptr->left_ && ival.high () <= ptr->left_ ->max ())
1126
1126
{
1127
1127
// no right? can only continue left
1128
- if (!ptr->right_ )
1129
- return find_all_i<IteratorT>(ptr->left_ , ival, on_find, compare);
1130
-
1131
- // upper bounds higher than what is contained right? continue left
1132
- if (ival.high () > ptr->right_ ->max ())
1128
+ if (!ptr->right_ || ival.low () > ptr->right_ ->max ())
1133
1129
return find_all_i<IteratorT>(ptr->left_ , ival, on_find, compare);
1134
1130
1135
1131
if (!find_all_i<IteratorT>(ptr->left_ , ival, on_find, compare))
1136
1132
return false ;
1137
1133
}
1138
1134
if (ptr->right_ && ival.high () <= ptr->right_ ->max ())
1139
1135
{
1140
- if (!ptr->left_ )
1141
- return find_all_i<IteratorT>(ptr->right_ , ival, on_find, compare);
1142
-
1143
- if (ival.high () > ptr->left_ ->max ())
1136
+ if (!ptr->left_ || ival.low () > ptr->left_ ->max ())
1144
1137
return find_all_i<IteratorT>(ptr->right_ , ival, on_find, compare);
1145
1138
1146
1139
if (!find_all_i<IteratorT>(ptr->right_ , ival, on_find, compare))
@@ -1165,11 +1158,7 @@ namespace lib_interval_tree
1165
1158
if (ptr->left_ && ival.high () <= ptr->left_ ->max ())
1166
1159
{
1167
1160
// no right? can only continue left
1168
- if (!ptr->right_ )
1169
- return find_i (ptr->left_ , ival, compare);
1170
-
1171
- // upper bounds higher than what is contained right? continue left
1172
- if (ival.high () > ptr->right_ ->max ())
1161
+ if (!ptr->right_ || ival.low () > ptr->right_ ->max ())
1173
1162
return find_i (ptr->left_ , ival, compare);
1174
1163
1175
1164
auto * res = find_i (ptr->left_ , ival, compare);
@@ -1178,10 +1167,7 @@ namespace lib_interval_tree
1178
1167
}
1179
1168
if (ptr->right_ && ival.high () <= ptr->right_ ->max ())
1180
1169
{
1181
- if (!ptr->left_ )
1182
- return find_i (ptr->right_ , ival, compare);
1183
-
1184
- if (ival.high () > ptr->left_ ->max ())
1170
+ if (!ptr->left_ || ival.low () > ptr->left_ ->max ())
1185
1171
return find_i (ptr->right_ , ival, compare);
1186
1172
1187
1173
auto * res = find_i (ptr->right_ , ival, compare);
@@ -1242,22 +1228,16 @@ namespace lib_interval_tree
1242
1228
if (ptr->left_ && ptr->left_ ->max () >= ival.low ())
1243
1229
{
1244
1230
// no right? can only continue left
1245
- if (!ptr->right_ )
1246
- return overlap_find_all_i<Exclusive, IteratorT>(ptr->left_ , ival, on_find);
1247
-
1248
- // upper bounds higher than what is contained right? continue left
1249
- if (ival.high () > ptr->right_ ->max ())
1231
+ // or interval low is bigger than max of right branch.
1232
+ if (!ptr->right_ || ival.low () > ptr->right_ ->max ())
1250
1233
return overlap_find_all_i<Exclusive, IteratorT>(ptr->left_ , ival, on_find);
1251
1234
1252
1235
if (!overlap_find_all_i<Exclusive, IteratorT>(ptr->left_ , ival, on_find))
1253
1236
return false ;
1254
1237
}
1255
1238
if (ptr->right_ && ptr->right_ ->max () >= ival.low ())
1256
1239
{
1257
- if (!ptr->left_ )
1258
- return overlap_find_all_i<Exclusive, IteratorT>(ptr->right_ , ival, on_find);
1259
-
1260
- if (ival.high () > ptr->left_ ->max ())
1240
+ if (!ptr->left_ || ival.low () > ptr->right_ ->max ())
1261
1241
return overlap_find_all_i<Exclusive, IteratorT>(ptr->right_ , ival, on_find);
1262
1242
1263
1243
if (!overlap_find_all_i<Exclusive, IteratorT>(ptr->right_ , ival, on_find))
@@ -1273,11 +1253,8 @@ namespace lib_interval_tree
1273
1253
if (ptr->left_ && ptr->left_ ->max () >= ival.low ())
1274
1254
{
1275
1255
// no right? can only continue left
1276
- if (!ptr->right_ )
1277
- return overlap_find_i<Exclusive>(ptr->left_ , ival);
1278
-
1279
- // upper bounds higher than what is contained right? continue left
1280
- if (ival.high () > ptr->right_ ->max ())
1256
+ // or upper bounds higher than what is contained right? continue left.
1257
+ if (!ptr->right_ || ival.low () > ptr->right_ ->max ())
1281
1258
return overlap_find_i<Exclusive>(ptr->left_ , ival);
1282
1259
1283
1260
auto * res = overlap_find_i<Exclusive>(ptr->left_ , ival);
@@ -1286,10 +1263,7 @@ namespace lib_interval_tree
1286
1263
}
1287
1264
if (ptr->right_ && ptr->right_ ->max () >= ival.low ())
1288
1265
{
1289
- if (!ptr->left_ )
1290
- return overlap_find_i<Exclusive>(ptr->right_ , ival);
1291
-
1292
- if (ival.high () > ptr->left_ ->max ())
1266
+ if (!ptr->left_ || ival.low () > ptr->left_ ->max ())
1293
1267
return overlap_find_i<Exclusive>(ptr->right_ , ival);
1294
1268
1295
1269
auto * res = overlap_find_i<Exclusive>(ptr->right_ , ival);
0 commit comments