In various settings, I need to efficiently find the indices of all elements of a sorted vector/range that belong to an interval, e.g. within_interval(1:0.5:8, 2..4) -> 3:7, whereas within_interval(1:0.5:8, Interval{:closed,:open}(2,4) -> 3:6. Would this be an interesting addition to IntervalSets.jl?
For ranges, one can do a little bit of algebra to find the indices [O(1) complexity], whereas for sorted vectors I guess bisection [O(N*log(N))] is the best one can do.
In various settings, I need to efficiently find the indices of all elements of a sorted vector/range that belong to an interval, e.g.
within_interval(1:0.5:8, 2..4) -> 3:7, whereaswithin_interval(1:0.5:8, Interval{:closed,:open}(2,4) -> 3:6. Would this be an interesting addition to IntervalSets.jl?For ranges, one can do a little bit of algebra to find the indices [O(1) complexity], whereas for sorted vectors I guess bisection [O(N*log(N))] is the best one can do.