3 ms·
In the past for this sort of thing I've used an interval tree https://en.wikipedia.org/wiki/Interval_tree https://en.wikipedia.org/wiki/Interval_tree However,
by neutrinobro 2y ago
In the past for this sort of thing I've used an interval tree
https://en.wikipedia.org/wiki/Interval_tree https://en.wikipedia.org/wiki/Interval_tree
However, that was mainly for the case where I needed to detect overlapping intervals. Depending on your application perhaps a K-d tree, in this case, K=2 (one dimension for start-time the other for the end-time)? If you know that all you intervals are entirely disjoint (no overlap at all) I don't think you'll be able to do better than just an ordered map or list.