Commit 3e875efe authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 5516f5a6
......@@ -41,7 +41,7 @@ type RangedMap struct {
// RangedMapEntry represents one entry in RangedMap.
type RangedMapEntry struct {
KeyRange
Value VALUE
Value VALUE
}
......@@ -170,17 +170,21 @@ func (M *RangedMap) SetRange(r KeyRange, v VALUE) {
// and check if we should merge it with right/left neighbours
if ilo+1 < len(M.entryv) { // right
if M.entryv[ilo].Hi_+1 == M.entryv[ilo+1].Lo { // XXX && .Value same
x := M.entryv[ilo]
right := M.entryv[ilo+1]
if (x.Hi_+1 == right.Lo) && (x.Value == right.Value) {
vReplaceSlice(&M.entryv, ilo,ilo+2,
KeyRange{M.entryv[ilo].Lo, M.entryv[ilo+1].Hi_})
RangedMapEntry{KeyRange{x.Lo, right.Hi_}, x.Value})
debugfRMap("\tmerge right\t-> %s\n", M)
}
}
if ilo > 0 { // left
if M.entryv[ilo-1].Hi_+1 == M.entryv[ilo].Lo { // XXX && .Value same
left := M.entryv[ilo-1]
x := M.entryv[ilo]
if (left.Hi_+1 == x.Lo) && (left.Value == x.Value) {
vReplaceSlice(&M.entryv, ilo-1,ilo+1,
KeyRange{M.entryv[ilo-1].Lo, M.entryv[ilo].Hi_})
RangedMapEntry{KeyRange{left.Lo, x.Hi_}, x.Value})
debugfRMap("\tmerge left\t-> %s\n", M)
}
}
......
......@@ -43,7 +43,7 @@ type _RangedMap_str struct {
// _RangedMap_strEntry represents one entry in _RangedMap_str.
type _RangedMap_strEntry struct {
KeyRange
Value string
Value string
}
......@@ -172,17 +172,21 @@ func (M *_RangedMap_str) SetRange(r KeyRange, v string) {
// and check if we should merge it with right/left neighbours
if ilo+1 < len(M.entryv) { // right
if M.entryv[ilo].Hi_+1 == M.entryv[ilo+1].Lo { // XXX && .Value same
x := M.entryv[ilo]
right := M.entryv[ilo+1]
if (x.Hi_+1 == right.Lo) && (x.Value == right.Value) {
vReplaceSlice__RangedMap_str(&M.entryv, ilo,ilo+2,
KeyRange{M.entryv[ilo].Lo, M.entryv[ilo+1].Hi_})
_RangedMap_strEntry{KeyRange{x.Lo, right.Hi_}, x.Value})
debugf_RangedMap_str("\tmerge right\t-> %s\n", M)
}
}
if ilo > 0 { // left
if M.entryv[ilo-1].Hi_+1 == M.entryv[ilo].Lo { // XXX && .Value same
left := M.entryv[ilo-1]
x := M.entryv[ilo]
if (left.Hi_+1 == x.Lo) && (left.Value == x.Value) {
vReplaceSlice__RangedMap_str(&M.entryv, ilo-1,ilo+1,
KeyRange{M.entryv[ilo-1].Lo, M.entryv[ilo].Hi_})
_RangedMap_strEntry{KeyRange{left.Lo, x.Hi_}, x.Value})
debugf_RangedMap_str("\tmerge left\t-> %s\n", M)
}
}
......
......@@ -43,7 +43,7 @@ type _RangedMap_void struct {
// _RangedMap_voidEntry represents one entry in _RangedMap_void.
type _RangedMap_voidEntry struct {
KeyRange
Value void
Value void
}
......@@ -172,17 +172,21 @@ func (M *_RangedMap_void) SetRange(r KeyRange, v void) {
// and check if we should merge it with right/left neighbours
if ilo+1 < len(M.entryv) { // right
if M.entryv[ilo].Hi_+1 == M.entryv[ilo+1].Lo { // XXX && .Value same
x := M.entryv[ilo]
right := M.entryv[ilo+1]
if (x.Hi_+1 == right.Lo) && (x.Value == right.Value) {
vReplaceSlice__RangedMap_void(&M.entryv, ilo,ilo+2,
KeyRange{M.entryv[ilo].Lo, M.entryv[ilo+1].Hi_})
_RangedMap_voidEntry{KeyRange{x.Lo, right.Hi_}, x.Value})
debugf_RangedMap_void("\tmerge right\t-> %s\n", M)
}
}
if ilo > 0 { // left
if M.entryv[ilo-1].Hi_+1 == M.entryv[ilo].Lo { // XXX && .Value same
left := M.entryv[ilo-1]
x := M.entryv[ilo]
if (left.Hi_+1 == x.Lo) && (left.Value == x.Value) {
vReplaceSlice__RangedMap_void(&M.entryv, ilo-1,ilo+1,
KeyRange{M.entryv[ilo-1].Lo, M.entryv[ilo].Hi_})
_RangedMap_voidEntry{KeyRange{left.Lo, x.Hi_}, x.Value})
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