std.container.rbtree as Interval Tree?
razvan.nitu1305 at gmail.com
Tue Feb 5 10:10:44 UTC 2019
On Monday, 4 February 2019 at 22:54:01 UTC, James Blachly wrote:
> I tried to implement an interval tree backed by
> std.container.rbtree today and fell flat.
You can use alias this  in your interval element type:
size_t start, end;
/* ... other declarations */
alias start this;
> Q2: Would replacing "Elem" with a generic type "T" in the
> function signatures for upperBound, lowerBound, and various
> related fns like _firstGreater / _firstGreaterEqual solve this
Elem is already a generic type. I don't know how you can make it
more generic without adding other template parameters to the
class declaration (which means reimplementing RBTree from
>  https://dlang.org/spec/operatoroverloading.html#eqcmp ("For
> example ... x and y are disjoint sets, then neither x < y nor y
> < x holds, but that does not imply that x == y. Thus, it is
> insufficient to determine equality purely based on opCmp alone.
More information about the Digitalmars-d-learn