[ICL] Specific interval_map
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. BR, AG.
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
2012/9/29 Joachim Faulhaber
. 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:
Hello Joachim,
Thank you for your feedback. I took a wrong example. Intervals represent memory in my case, and with each interval, I have an aggregated object from an ad-hoc class, which represents the memory value at the given "memory interval". I thought I could simplify my example stating I need the size of the interval, but it is a wrong simplification in my case. Therefore each time I need to resize an interval, the memory value corresponding to it must be updated (either cutting its lower or upper part). I understand that the split_interval_map is probably not the best container for this, because I need something different from an simple aggregation on overlap. You suggested working with split_interval_set() but then I would need to customize the addition function of two overlapping interval. This is probably not open in your library. Do you confirm, and if so do you also confirm it is best for me to design my own container ? BR, AG.
participants (2)
-
A G
-
Joachim Faulhaber