Skip to content

Quickly find elements of vector covered by interval #52

@jagot

Description

@jagot

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions