parent
0476bcad1b
commit
1e86bd1ef3
|
@ -426,14 +426,15 @@ proc merge[P,S](ds: Desc[P,S]; iv: Segm[P,S]): Segm[P,S] =
|
||||||
# iv: ...----------------)
|
# iv: ...----------------)
|
||||||
# p: ...-----)
|
# p: ...-----)
|
||||||
#
|
#
|
||||||
p.blk.size += iv.len # update database
|
let extend = iv.right - p.right
|
||||||
ds.ptsCount += iv.len # update database
|
p.blk.size += extend # update database
|
||||||
|
ds.ptsCount += extend # update database
|
||||||
#
|
#
|
||||||
# iv: ...----------------)
|
# iv: ...----------------)
|
||||||
# p: ...----------------)
|
# p: ...----------------)
|
||||||
# result: [---------)
|
# result: [---------)
|
||||||
#
|
#
|
||||||
return Segm[P,S].new(p.right, iv.right)
|
return Segm[P,S].new(p.right - extend, iv.right)
|
||||||
|
|
||||||
# now: iv.right <= p.right and p.left <= iv.left:
|
# now: iv.right <= p.right and p.left <= iv.left:
|
||||||
if p.left <= iv.left:
|
if p.left <= iv.left:
|
||||||
|
|
|
@ -239,6 +239,18 @@ suite "IntervalSet: Intervals of FancyPoint entries over FancyScalar":
|
||||||
check br.ge(uHigh) == iv(uHigh,uHigh)
|
check br.ge(uHigh) == iv(uHigh,uHigh)
|
||||||
check br.envelope(uHigh) == iv(uHigh,uHigh)
|
check br.envelope(uHigh) == iv(uHigh,uHigh)
|
||||||
|
|
||||||
|
test "Merge overlapping intervals":
|
||||||
|
br.clear()
|
||||||
|
check br.merge(100, 199) == 100
|
||||||
|
check br.merge(150, 200) == 1
|
||||||
|
check br.total == 101
|
||||||
|
check br.chunks == 1
|
||||||
|
check br.verify.isOk
|
||||||
|
check br.merge( 99, 150) == 1
|
||||||
|
check br.total == 102
|
||||||
|
check br.chunks == 1
|
||||||
|
check br.verify.isOk
|
||||||
|
|
||||||
test "Merge disjunct intervals on 1st set":
|
test "Merge disjunct intervals on 1st set":
|
||||||
br.clear()
|
br.clear()
|
||||||
check br.merge( 0, 99) == 100
|
check br.merge( 0, 99) == 100
|
||||||
|
|
Loading…
Reference in New Issue