2012/9/27 A G
Hello,
I am trying to see whether I can use interval_map for my project. I was initially amazed with interval_map and thought this would be it, but then I have some doubts:
I need a interval tree like interval_map, but the aggregated values have the following equivalent property: equal to the length of the interval it is aggregated with. An example:
[0:3] -> 3 [4:8] -> 4
Then if I add the interval [2:5] with aggregated value 3 (step 1) to this container, this should end up with:
[0:1] -> 1 [2:3] -> 1 [4:5] -> 1 [6:8] -> 2
which I would later need to change into (step 2) :
[0:1] -> 1 [2:5] -> 3 ([2:3] and [4:5] are merged because what matter is the last inserted interval: [2:3]). [6:8] -> 2
I am not sure I can do step 1 in just overloading the operator+= over my aggregated values. Could you please confirm ? If so, is there any part of the library I can reuse to do this task (like a function overloading, but which one) or do I have to rewrite an ad-hoc insert-like method myself ?
Thank you for your hints.
The use case you are suggesting is probably beyond the idea of
aggregating associated values on overlap. Moreover the value you
intend to associate to intervals, their size, is already available via
the icl::size function on intervals.
I think the behavior that you intend can be obtained using an
icl::split_interval_set in the following way:
=========================================================
#include