guava icon indicating copy to clipboard operation
guava copied to clipboard

Add RangeMap.mergeCoalescing

Open perceptron8 opened this issue 6 years ago • 1 comments

Please consider addition of RangeMap.mergeCoalescing analogous to RangeMap.putCoalescing. It would be a great complement of RangeMap.merge.

I wish that you had choosen one-off coalesce operation rather than mutating one (see https://github.com/google/guava/issues/2665), as it would be helpful in this use case as well.

perceptron8 avatar Oct 04 '19 08:10 perceptron8

I don't expect this comment to move things forward (quite the opposite probably?), but I'll leave it here as a memo anyway.

Although it's rather clear that [[0..1)=1, [1..2)=0, [2..3)=1].mergeCoalescing([1..2), 1, (a, b) -> a + b) should return [0, 3) = 1 it's not clear at all whether [[0..1)=1, [1..2)=0, [2..3)=0, [3..4)=0, [4..5)=1].mergeCoalescing([1..4), 1, (a, b) -> a + b) should return [[0..2)=1, [2..3)=1, [3..5)=1] or [[0..5)=1].

You've probably discovered this and much more similar flaws long time ago.

Surprisingly, I believe this seems to be an argument in favor of RangeMaps.coalesced (https://github.com/google/guava/issues/2665#issuecomment-263950416).

perceptron8 avatar Nov 06 '23 14:11 perceptron8