@@ -218,9 +218,9 @@ namespace lib_interval_tree
218218 {
219219 }
220220
221- interval_type interval () const
221+ interval_type const * interval () const
222222 {
223- return interval_;
223+ return & interval_;
224224 }
225225
226226 value_type max () const
@@ -382,7 +382,12 @@ namespace lib_interval_tree
382382
383383 typename tree_type::interval_type interval () const
384384 {
385- return node_->interval ();
385+ return *node_->interval ();
386+ }
387+
388+ node_ptr_t node () const
389+ {
390+ return node_;
386391 }
387392
388393 virtual ~basic_interval_tree_iterator () = default ;
@@ -464,7 +469,7 @@ namespace lib_interval_tree
464469 typename value_type::interval_type operator *() const
465470 {
466471 if (node_)
467- return node_->interval ();
472+ return * node_->interval ();
468473 else
469474 throw std::out_of_range (" dereferencing interval_tree_iterator out of bounds" );
470475 }
@@ -505,9 +510,12 @@ namespace lib_interval_tree
505510 throw std::out_of_range (" interval_tree_iterator out of bounds" );
506511 }
507512
508- value_type const * operator ->() const
513+ typename value_type::interval_type * operator ->() const
509514 {
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" );
511519 }
512520
513521 private:
@@ -618,14 +626,17 @@ namespace lib_interval_tree
618626 typename value_type::interval_type operator *() const
619627 {
620628 if (node_)
621- return node_->interval ();
629+ return * node_->interval ();
622630 else
623631 throw std::out_of_range (" interval_tree_iterator out of bounds" );
624632 }
625633
626- value_type* operator ->()
634+ typename value_type::interval_type const * operator ->() const
627635 {
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" );
629640 }
630641
631642 private:
@@ -776,8 +787,8 @@ namespace lib_interval_tree
776787 return insert (ival);
777788 else
778789 {
779- auto mergeSet = iter-> interval ().join (ival);
780- erase (iter);
790+ auto mergeSet = iter. interval ().join (ival);
791+ erase (iter);
781792 return insert_merge_set (mergeSet, mergeSetOverlapping);
782793 }
783794 }
@@ -1061,7 +1072,7 @@ namespace lib_interval_tree
10611072 {
10621073 if (empty ())
10631074 return {};
1064- auto min = std::begin (*this )->interval (). low ();
1075+ auto min = std::begin (*this )->interval ()-> low ();
10651076 auto max = root_->max_ ;
10661077 return punch ({min, max});
10671078 }
@@ -1078,20 +1089,20 @@ namespace lib_interval_tree
10781089
10791090 interval_tree result;
10801091 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 ()});
10831094
10841095 for (auto e = end (); i != e; ++i)
10851096 {
10861097 auto next = i; ++next;
10871098 if (next != e)
1088- result.insert ({i->interval (). high (), next->interval (). low ()});
1099+ result.insert ({i->interval ()-> high (), next->interval ()-> low ()});
10891100 else
10901101 break ;
10911102 }
10921103
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 ()});
10951106
10961107 return result;
10971108 }
@@ -1162,9 +1173,9 @@ namespace lib_interval_tree
11621173 };
11631174
11641175 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)
11661177 {
1167- if (mergeSetOverlapping)
1178+ if (mergeSetOverlapping)
11681179 {
11691180 for (auto iter = merge_set.begin (), end = merge_set.end (); iter != end;)
11701181 {
@@ -1177,7 +1188,7 @@ namespace lib_interval_tree
11771188 }
11781189 return end ();
11791190 }
1180- else
1191+ else
11811192 {
11821193 for (auto iter = merge_set.begin (), end = merge_set.end (); iter != end;)
11831194 {
@@ -1215,7 +1226,7 @@ namespace lib_interval_tree
12151226 ComparatorFunctionT const & compare
12161227 )
12171228 {
1218- if (compare (ptr->interval (), ival))
1229+ if (compare (* ptr->interval (), ival))
12191230 {
12201231 if (!on_find (IteratorT{ptr, self}))
12211232 return false ;
@@ -1243,7 +1254,7 @@ namespace lib_interval_tree
12431254 template <typename ComparatorFunctionT>
12441255 node_type* find_i (node_type* ptr, interval_type const & ival, ComparatorFunctionT const & compare) const
12451256 {
1246- if (compare (ptr->interval (), ival))
1257+ if (compare (* ptr->interval (), ival))
12471258 return ptr;
12481259 else
12491260 return find_i_ex (ptr, ival, compare);
@@ -1284,12 +1295,12 @@ namespace lib_interval_tree
12841295 if (Exclusive)
12851296#endif
12861297 {
1287- if (ptr->interval (). overlaps_exclusive (ival))
1298+ if (ptr->interval ()-> overlaps_exclusive (ival))
12881299 return ptr;
12891300 }
12901301 else
12911302 {
1292- if (ptr->interval (). overlaps (ival))
1303+ if (ptr->interval ()-> overlaps (ival))
12931304 return ptr;
12941305 }
12951306
@@ -1311,7 +1322,7 @@ namespace lib_interval_tree
13111322 if (Exclusive)
13121323#endif
13131324 {
1314- if (ptr->interval (). overlaps_exclusive (ival))
1325+ if (ptr->interval ()-> overlaps_exclusive (ival))
13151326 {
13161327 if (!on_find (IteratorT{ptr, self}))
13171328 {
@@ -1321,7 +1332,7 @@ namespace lib_interval_tree
13211332 }
13221333 else
13231334 {
1324- if (ptr->interval (). overlaps (ival))
1335+ if (ptr->interval ()-> overlaps (ival))
13251336 {
13261337 if (!on_find (IteratorT{ptr, self}))
13271338 {
0 commit comments