Commit 9b3d1b48 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 0826205c
...@@ -210,7 +210,7 @@ func (S *RangeSet) DelRange(r Range) { ...@@ -210,7 +210,7 @@ func (S *RangeSet) DelRange(r Range) {
Range{S.rangev[ilo].lo, r.lo-1}}, Range{S.rangev[ilo].lo, r.lo-1}},
S.rangev[ilo+1:]...)...) S.rangev[ilo+1:]...)...)
ilo++ ilo++
debugfRSet("\tshrink left\t-> %s\n", S) debugfRSet("\tshrink [%d] left\t-> %s\n", ilo, S)
} }
if r.hi_ < S.rangev[jhi-1].hi_ { // shrink right if r.hi_ < S.rangev[jhi-1].hi_ { // shrink right
S.rangev = append( S.rangev = append(
...@@ -218,7 +218,7 @@ func (S *RangeSet) DelRange(r Range) { ...@@ -218,7 +218,7 @@ func (S *RangeSet) DelRange(r Range) {
Range{r.hi_+1, S.rangev[jhi-1].hi_}}, Range{r.hi_+1, S.rangev[jhi-1].hi_}},
S.rangev[jhi:]...)...) S.rangev[jhi:]...)...)
jhi-- jhi--
debugfRSet("\tshrink right\t-> %s\n", S) debugfRSet("\tshrink [%d] right\t-> %s\n", jhi-1, S)
} }
if (jhi - ilo) > 0 { if (jhi - ilo) > 0 {
......
...@@ -106,6 +106,14 @@ func TestRangeSet(t *testing.T) { ...@@ -106,6 +106,14 @@ func TestRangeSet(t *testing.T) {
S(3,5), // B S(3,5), // B
S(1,7), // U S(1,7), // U
S(1,3, 5,7)), // D S(1,3, 5,7)), // D
// delete covering several ranges
// [-1,0) [1,3) [5,7) [9,11) [15,20) [100,200) \ [2,17)
E(
S(-1,0, 1,3, 5,7, 9,11, 15,20, 100,200), // A
S(2,17), // B
S(-1,0, 1,20, 100,200), // U
S(-1,0, 1,2, 17,20, 100,200)), // D
} }
for _, tt := range testv { for _, tt := range testv {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment