-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Implement SegmentTree #72
Conversation
} | ||
} | ||
|
||
subscript(interval: Interval<Metric>) -> SegmentTree { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the intended usage for subscript? seems like there are so many ways to implement it. it could even return [SegmentTree]
. I think I would expect it to be either (1) an (ordered) list of the leaves whose given intervals fit inside interval
(which could have a pretty nice recursive design), or (2) the largest SegmentTree
that fits inside interval
, with a precondition/error throw if none exists (which could also have a nice recursion).
fatalError() | ||
} | ||
|
||
func interval(containing offset: Metric, including bound: Interval<Metric>.Bound) -> Interval<Metric>? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a little confused on the design here. is the idea to support interval queries for both open and closed sets? (like [a, b]
, [a, b)
, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mainly asking because the choices you've given are limiting and also I'm not sure i like the idea of this behavior changing within the same function
} | ||
} | ||
|
||
enum SegmentTree <Metric: SignedNumeric & Comparable> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does SegmentTree
fit into this design? i think this is a pretty interesting representation. wondering if duplicating the LHS and RHS bounds is necessary at every level; is that a simplicity/performance thing? because you could also define interval recursively as (left subtree's left bound, right subtree's right bound) in the branch case
See #166. |
Ordered collections of intervals are ever present in models of music, as well as graphics.
SegmentTree
structures provide a quicker access to interval-spanning elements than linear structures.Furthermore, this will create a unified interface for similar interval-spanning structures.