Commit fb34c8b7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 3e875efe
......@@ -142,11 +142,12 @@ func (M *RangedMap) SetRange(r KeyRange, v VALUE) {
debugfRMap("\tjhi: %d\n", jhi)
// entries in [ilo:jhi) [r.Lo,r.hi) and should be merged into one
// XXX check different values
// FIXME check different values
if (jhi - ilo) > 1 {
lo := M.entryv[ilo].Lo
hi_ := M.entryv[jhi-1].Hi_
vReplaceSlice(&M.entryv, ilo,jhi, KeyRange{lo,hi_})
//vReplaceSlice(&M.entryv, ilo,jhi, KeyRange{lo,hi_})
vReplaceSlice(&M.entryv, ilo,jhi, RangedMapEntry{KeyRange{lo,hi_}, v})
debugfRMap("\tmerge M[%d:%d]\t-> %s\n", ilo, jhi, M)
}
jhi = -1 // no longer valid
......@@ -172,9 +173,9 @@ func (M *RangedMap) SetRange(r KeyRange, v VALUE) {
if ilo+1 < len(M.entryv) { // right
x := M.entryv[ilo]
right := M.entryv[ilo+1]
if (x.Hi_+1 == right.Lo) && (x.Value == right.Value) {
if (x.Hi_+1 == right.Lo) && (v == right.Value) {
vReplaceSlice(&M.entryv, ilo,ilo+2,
RangedMapEntry{KeyRange{x.Lo, right.Hi_}, x.Value})
RangedMapEntry{KeyRange{x.Lo, right.Hi_}, v})
debugfRMap("\tmerge right\t-> %s\n", M)
}
}
......@@ -182,9 +183,9 @@ func (M *RangedMap) SetRange(r KeyRange, v VALUE) {
if ilo > 0 { // left
left := M.entryv[ilo-1]
x := M.entryv[ilo]
if (left.Hi_+1 == x.Lo) && (left.Value == x.Value) {
if (left.Hi_+1 == x.Lo) && (left.Value == v) {
vReplaceSlice(&M.entryv, ilo-1,ilo+1,
RangedMapEntry{KeyRange{left.Lo, x.Hi_}, x.Value})
RangedMapEntry{KeyRange{left.Lo, x.Hi_}, v})
debugfRMap("\tmerge left\t-> %s\n", M)
}
}
......
......@@ -144,11 +144,12 @@ func (M *_RangedMap_str) SetRange(r KeyRange, v string) {
debugf_RangedMap_str("\tjhi: %d\n", jhi)
// entries in [ilo:jhi) ∈ [r.Lo,r.hi) and should be merged into one
// XXX check different values
// FIXME check different values
if (jhi - ilo) > 1 {
lo := M.entryv[ilo].Lo
hi_ := M.entryv[jhi-1].Hi_
vReplaceSlice__RangedMap_str(&M.entryv, ilo,jhi, KeyRange{lo,hi_})
//vReplaceSlice__RangedMap_str(&M.entryv, ilo,jhi, KeyRange{lo,hi_})
vReplaceSlice__RangedMap_str(&M.entryv, ilo,jhi, _RangedMap_strEntry{KeyRange{lo,hi_}, v})
debugf_RangedMap_str("\tmerge M[%d:%d]\t-> %s\n", ilo, jhi, M)
}
jhi = -1 // no longer valid
......@@ -174,9 +175,9 @@ func (M *_RangedMap_str) SetRange(r KeyRange, v string) {
if ilo+1 < len(M.entryv) { // right
x := M.entryv[ilo]
right := M.entryv[ilo+1]
if (x.Hi_+1 == right.Lo) && (x.Value == right.Value) {
if (x.Hi_+1 == right.Lo) && (v == right.Value) {
vReplaceSlice__RangedMap_str(&M.entryv, ilo,ilo+2,
_RangedMap_strEntry{KeyRange{x.Lo, right.Hi_}, x.Value})
_RangedMap_strEntry{KeyRange{x.Lo, right.Hi_}, v})
debugf_RangedMap_str("\tmerge right\t-> %s\n", M)
}
}
......@@ -184,9 +185,9 @@ func (M *_RangedMap_str) SetRange(r KeyRange, v string) {
if ilo > 0 { // left
left := M.entryv[ilo-1]
x := M.entryv[ilo]
if (left.Hi_+1 == x.Lo) && (left.Value == x.Value) {
if (left.Hi_+1 == x.Lo) && (left.Value == v) {
vReplaceSlice__RangedMap_str(&M.entryv, ilo-1,ilo+1,
_RangedMap_strEntry{KeyRange{left.Lo, x.Hi_}, x.Value})
_RangedMap_strEntry{KeyRange{left.Lo, x.Hi_}, v})
debugf_RangedMap_str("\tmerge left\t-> %s\n", M)
}
}
......
......@@ -144,11 +144,12 @@ func (M *_RangedMap_void) SetRange(r KeyRange, v void) {
debugf_RangedMap_void("\tjhi: %d\n", jhi)
// entries in [ilo:jhi) ∈ [r.Lo,r.hi) and should be merged into one
// XXX check different values
// FIXME check different values
if (jhi - ilo) > 1 {
lo := M.entryv[ilo].Lo
hi_ := M.entryv[jhi-1].Hi_
vReplaceSlice__RangedMap_void(&M.entryv, ilo,jhi, KeyRange{lo,hi_})
//vReplaceSlice__RangedMap_void(&M.entryv, ilo,jhi, KeyRange{lo,hi_})
vReplaceSlice__RangedMap_void(&M.entryv, ilo,jhi, _RangedMap_voidEntry{KeyRange{lo,hi_}, v})
debugf_RangedMap_void("\tmerge M[%d:%d]\t-> %s\n", ilo, jhi, M)
}
jhi = -1 // no longer valid
......@@ -174,9 +175,9 @@ func (M *_RangedMap_void) SetRange(r KeyRange, v void) {
if ilo+1 < len(M.entryv) { // right
x := M.entryv[ilo]
right := M.entryv[ilo+1]
if (x.Hi_+1 == right.Lo) && (x.Value == right.Value) {
if (x.Hi_+1 == right.Lo) && (v == right.Value) {
vReplaceSlice__RangedMap_void(&M.entryv, ilo,ilo+2,
_RangedMap_voidEntry{KeyRange{x.Lo, right.Hi_}, x.Value})
_RangedMap_voidEntry{KeyRange{x.Lo, right.Hi_}, v})
debugf_RangedMap_void("\tmerge right\t-> %s\n", M)
}
}
......@@ -184,9 +185,9 @@ func (M *_RangedMap_void) SetRange(r KeyRange, v void) {
if ilo > 0 { // left
left := M.entryv[ilo-1]
x := M.entryv[ilo]
if (left.Hi_+1 == x.Lo) && (left.Value == x.Value) {
if (left.Hi_+1 == x.Lo) && (left.Value == v) {
vReplaceSlice__RangedMap_void(&M.entryv, ilo-1,ilo+1,
_RangedMap_voidEntry{KeyRange{left.Lo, x.Hi_}, x.Value})
_RangedMap_voidEntry{KeyRange{left.Lo, x.Hi_}, v})
debugf_RangedMap_void("\tmerge left\t-> %s\n", M)
}
}
......
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