@@ -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,16 +1228,16 @@ namespace lib_interval_tree
12421228 if (ptr->left_ && ptr->left_ ->max () >= ival.low ())
12431229 {
12441230 // no right? can only continue left
1245- // or upper bound is lower than what is contained right? continue left
1246- if (!ptr->right_ || ival.high () < ptr->right_ ->low ())
1231+ // or interval low is bigger than max of right branch.
1232+ if (!ptr->right_ || ival.low () > ptr->right_ ->max ())
12471233 return overlap_find_all_i<Exclusive, IteratorT>(ptr->left_ , ival, on_find);
12481234
12491235 if (!overlap_find_all_i<Exclusive, IteratorT>(ptr->left_ , ival, on_find))
12501236 return false ;
12511237 }
12521238 if (ptr->right_ && ptr->right_ ->max () >= ival.low ())
12531239 {
1254- if (!ptr->left_ || ival.high () < ptr->left_ -> low ())
1240+ if (!ptr->left_ || ival.low () > ptr->right_ -> max ())
12551241 return overlap_find_all_i<Exclusive, IteratorT>(ptr->right_ , ival, on_find);
12561242
12571243 if (!overlap_find_all_i<Exclusive, IteratorT>(ptr->right_ , ival, on_find))
@@ -1267,11 +1253,8 @@ namespace lib_interval_tree
12671253 if (ptr->left_ && ptr->left_ ->max () >= ival.low ())
12681254 {
12691255 // no right? can only continue left
1270- if (!ptr->right_ )
1271- return overlap_find_i<Exclusive>(ptr->left_ , ival);
1272-
1273- // upper bounds higher than what is contained right? continue left
1274- 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 ())
12751258 return overlap_find_i<Exclusive>(ptr->left_ , ival);
12761259
12771260 auto * res = overlap_find_i<Exclusive>(ptr->left_ , ival);
@@ -1280,10 +1263,7 @@ namespace lib_interval_tree
12801263 }
12811264 if (ptr->right_ && ptr->right_ ->max () >= ival.low ())
12821265 {
1283- if (!ptr->left_ )
1284- return overlap_find_i<Exclusive>(ptr->right_ , ival);
1285-
1286- if (ival.high () > ptr->left_ ->max ())
1266+ if (!ptr->left_ || ival.low () > ptr->left_ ->max ())
12871267 return overlap_find_i<Exclusive>(ptr->right_ , ival);
12881268
12891269 auto * res = overlap_find_i<Exclusive>(ptr->right_ , ival);
0 commit comments