@@ -1125,22 +1125,15 @@ namespace lib_interval_tree
11251125 if (ptr->left_ && ival.high () <= ptr->left_ ->max ())
11261126 {
11271127 // 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 ())
11331129 return find_all_i<IteratorT>(ptr->left_ , ival, on_find, compare);
11341130
11351131 if (!find_all_i<IteratorT>(ptr->left_ , ival, on_find, compare))
11361132 return false ;
11371133 }
11381134 if (ptr->right_ && ival.high () <= ptr->right_ ->max ())
11391135 {
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 ())
11441137 return find_all_i<IteratorT>(ptr->right_ , ival, on_find, compare);
11451138
11461139 if (!find_all_i<IteratorT>(ptr->right_ , ival, on_find, compare))
@@ -1165,11 +1158,7 @@ namespace lib_interval_tree
11651158 if (ptr->left_ && ival.high () <= ptr->left_ ->max ())
11661159 {
11671160 // 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 ())
11731162 return find_i (ptr->left_ , ival, compare);
11741163
11751164 auto * res = find_i (ptr->left_ , ival, compare);
@@ -1178,10 +1167,7 @@ namespace lib_interval_tree
11781167 }
11791168 if (ptr->right_ && ival.high () <= ptr->right_ ->max ())
11801169 {
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 ())
11851171 return find_i (ptr->right_ , ival, compare);
11861172
11871173 auto * res = find_i (ptr->right_ , ival, compare);
@@ -1242,22 +1228,16 @@ namespace lib_interval_tree
12421228 if (ptr->left_ && ptr->left_ ->max () >= ival.low ())
12431229 {
12441230 // 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 ())
12501233 return overlap_find_all_i<Exclusive, IteratorT>(ptr->left_ , ival, on_find);
12511234
12521235 if (!overlap_find_all_i<Exclusive, IteratorT>(ptr->left_ , ival, on_find))
12531236 return false ;
12541237 }
12551238 if (ptr->right_ && ptr->right_ ->max () >= ival.low ())
12561239 {
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 ())
12611241 return overlap_find_all_i<Exclusive, IteratorT>(ptr->right_ , ival, on_find);
12621242
12631243 if (!overlap_find_all_i<Exclusive, IteratorT>(ptr->right_ , ival, on_find))
@@ -1273,11 +1253,8 @@ namespace lib_interval_tree
12731253 if (ptr->left_ && ptr->left_ ->max () >= ival.low ())
12741254 {
12751255 // 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 ())
12811258 return overlap_find_i<Exclusive>(ptr->left_ , ival);
12821259
12831260 auto * res = overlap_find_i<Exclusive>(ptr->left_ , ival);
@@ -1286,10 +1263,7 @@ namespace lib_interval_tree
12861263 }
12871264 if (ptr->right_ && ptr->right_ ->max () >= ival.low ())
12881265 {
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 ())
12931267 return overlap_find_i<Exclusive>(ptr->right_ , ival);
12941268
12951269 auto * res = overlap_find_i<Exclusive>(ptr->right_ , ival);
0 commit comments