@@ -218,9 +218,9 @@ namespace lib_interval_tree
218
218
{
219
219
}
220
220
221
- interval_type interval () const
221
+ interval_type const * interval () const
222
222
{
223
- return interval_;
223
+ return & interval_;
224
224
}
225
225
226
226
value_type max () const
@@ -382,7 +382,12 @@ namespace lib_interval_tree
382
382
383
383
typename tree_type::interval_type interval () const
384
384
{
385
- return node_->interval ();
385
+ return *node_->interval ();
386
+ }
387
+
388
+ node_ptr_t node () const
389
+ {
390
+ return node_;
386
391
}
387
392
388
393
virtual ~basic_interval_tree_iterator () = default ;
@@ -464,7 +469,7 @@ namespace lib_interval_tree
464
469
typename value_type::interval_type operator *() const
465
470
{
466
471
if (node_)
467
- return node_->interval ();
472
+ return * node_->interval ();
468
473
else
469
474
throw std::out_of_range (" dereferencing interval_tree_iterator out of bounds" );
470
475
}
@@ -505,9 +510,12 @@ namespace lib_interval_tree
505
510
throw std::out_of_range (" interval_tree_iterator out of bounds" );
506
511
}
507
512
508
- value_type const * operator ->() const
513
+ typename value_type::interval_type * operator ->() const
509
514
{
510
- return node_;
515
+ if (node_)
516
+ return node_->interval ();
517
+ else
518
+ throw std::out_of_range (" dereferencing interval_tree_iterator out of bounds" );
511
519
}
512
520
513
521
private:
@@ -618,14 +626,17 @@ namespace lib_interval_tree
618
626
typename value_type::interval_type operator *() const
619
627
{
620
628
if (node_)
621
- return node_->interval ();
629
+ return * node_->interval ();
622
630
else
623
631
throw std::out_of_range (" interval_tree_iterator out of bounds" );
624
632
}
625
633
626
- value_type* operator ->()
634
+ typename value_type::interval_type const * operator ->() const
627
635
{
628
- return node_;
636
+ if (node_)
637
+ return node_->interval ();
638
+ else
639
+ throw std::out_of_range (" dereferencing interval_tree_iterator out of bounds" );
629
640
}
630
641
631
642
private:
@@ -776,8 +787,8 @@ namespace lib_interval_tree
776
787
return insert (ival);
777
788
else
778
789
{
779
- auto mergeSet = iter-> interval ().join (ival);
780
- erase (iter);
790
+ auto mergeSet = iter. interval ().join (ival);
791
+ erase (iter);
781
792
return insert_merge_set (mergeSet, mergeSetOverlapping);
782
793
}
783
794
}
@@ -1061,7 +1072,7 @@ namespace lib_interval_tree
1061
1072
{
1062
1073
if (empty ())
1063
1074
return {};
1064
- auto min = std::begin (*this )->interval (). low ();
1075
+ auto min = std::begin (*this )->interval ()-> low ();
1065
1076
auto max = root_->max_ ;
1066
1077
return punch ({min, max});
1067
1078
}
@@ -1078,20 +1089,20 @@ namespace lib_interval_tree
1078
1089
1079
1090
interval_tree result;
1080
1091
auto i = std::begin (*this );
1081
- if (ival.low () < i->interval (). low ())
1082
- result.insert ({ival.low (), i->interval (). low ()});
1092
+ if (ival.low () < i->interval ()-> low ())
1093
+ result.insert ({ival.low (), i->interval ()-> low ()});
1083
1094
1084
1095
for (auto e = end (); i != e; ++i)
1085
1096
{
1086
1097
auto next = i; ++next;
1087
1098
if (next != e)
1088
- result.insert ({i->interval (). high (), next->interval (). low ()});
1099
+ result.insert ({i->interval ()-> high (), next->interval ()-> low ()});
1089
1100
else
1090
1101
break ;
1091
1102
}
1092
1103
1093
- if (i != end () && i->interval (). high () < ival.high ())
1094
- result.insert ({i->interval (). high (), ival.high ()});
1104
+ if (i != end () && i->interval ()-> high () < ival.high ())
1105
+ result.insert ({i->interval ()-> high (), ival.high ()});
1095
1106
1096
1107
return result;
1097
1108
}
@@ -1162,9 +1173,9 @@ namespace lib_interval_tree
1162
1173
};
1163
1174
1164
1175
template <typename MergeSet>
1165
- iterator insert_merge_set (MergeSet const & merge_set, bool mergeSetOverlapping)
1176
+ iterator insert_merge_set (MergeSet const & merge_set, bool mergeSetOverlapping)
1166
1177
{
1167
- if (mergeSetOverlapping)
1178
+ if (mergeSetOverlapping)
1168
1179
{
1169
1180
for (auto iter = merge_set.begin (), end = merge_set.end (); iter != end;)
1170
1181
{
@@ -1177,7 +1188,7 @@ namespace lib_interval_tree
1177
1188
}
1178
1189
return end ();
1179
1190
}
1180
- else
1191
+ else
1181
1192
{
1182
1193
for (auto iter = merge_set.begin (), end = merge_set.end (); iter != end;)
1183
1194
{
@@ -1215,7 +1226,7 @@ namespace lib_interval_tree
1215
1226
ComparatorFunctionT const & compare
1216
1227
)
1217
1228
{
1218
- if (compare (ptr->interval (), ival))
1229
+ if (compare (* ptr->interval (), ival))
1219
1230
{
1220
1231
if (!on_find (IteratorT{ptr, self}))
1221
1232
return false ;
@@ -1243,7 +1254,7 @@ namespace lib_interval_tree
1243
1254
template <typename ComparatorFunctionT>
1244
1255
node_type* find_i (node_type* ptr, interval_type const & ival, ComparatorFunctionT const & compare) const
1245
1256
{
1246
- if (compare (ptr->interval (), ival))
1257
+ if (compare (* ptr->interval (), ival))
1247
1258
return ptr;
1248
1259
else
1249
1260
return find_i_ex (ptr, ival, compare);
@@ -1284,12 +1295,12 @@ namespace lib_interval_tree
1284
1295
if (Exclusive)
1285
1296
#endif
1286
1297
{
1287
- if (ptr->interval (). overlaps_exclusive (ival))
1298
+ if (ptr->interval ()-> overlaps_exclusive (ival))
1288
1299
return ptr;
1289
1300
}
1290
1301
else
1291
1302
{
1292
- if (ptr->interval (). overlaps (ival))
1303
+ if (ptr->interval ()-> overlaps (ival))
1293
1304
return ptr;
1294
1305
}
1295
1306
@@ -1311,7 +1322,7 @@ namespace lib_interval_tree
1311
1322
if (Exclusive)
1312
1323
#endif
1313
1324
{
1314
- if (ptr->interval (). overlaps_exclusive (ival))
1325
+ if (ptr->interval ()-> overlaps_exclusive (ival))
1315
1326
{
1316
1327
if (!on_find (IteratorT{ptr, self}))
1317
1328
{
@@ -1321,7 +1332,7 @@ namespace lib_interval_tree
1321
1332
}
1322
1333
else
1323
1334
{
1324
- if (ptr->interval (). overlaps (ival))
1335
+ if (ptr->interval ()-> overlaps (ival))
1325
1336
{
1326
1337
if (!on_find (IteratorT{ptr, self}))
1327
1338
{
0 commit comments