Skip to content
12 changes: 12 additions & 0 deletions IntervalTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ class IntervalTree {
assert(is_valid().first);
}

Scalar min() const {
assert(!empty());
if (left) { return left->min(); }
return std::min_element(intervals.begin(), intervals.end(),
IntervalStartCmp())->start;
}
Scalar max() const {
Copy link
Contributor Author

@BenFrantzDale BenFrantzDale Apr 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct, or do we need to do max of right->max() and everything in this tree node?

assert(!empty());
if (right) { return right->max(); }
return std::max_element(intervals.begin(), intervals.end(),
IntervalStopCmp())->stop;
}
// Call f on all intervals near the range [start, stop]:
template <class UnaryFunction>
void visit_near(const Scalar& start, const Scalar& stop, UnaryFunction f) const {
Expand Down