Commit f1473c1c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7a2c53ce
......@@ -286,8 +286,33 @@ func (M *RangedMap) HasRange(r KeyRange) (yes bool) {
return false
}
// all keys from r are in M if r [ilo] XXX not in case of different values
return (M.entryv[ilo].Lo <= r.Lo && r.Hi_ <= M.entryv[ilo].Hi_)
lo := r.Lo
for {
e := M.entryv[ilo]
debugfRMap("\te: %s\ttocheck: %s\n", e, KeyRange{lo, r.Hi_})
if lo < e.Lo {
return false // hole in coverage
}
if r.Hi_ <= e.Hi_ {
return true // full coverage
}
lo = e.Hi_
if lo < KeyMax {
lo++
}
ilo++
if ilo == l {
return false // r's right not fully covered
}
}
// // all keys from r are in M if r ∈ [ilo] XXX not in case of different values
// return (M.entryv[ilo].Lo <= r.Lo && r.Hi_ <= M.entryv[ilo].Hi_)
}
......
......@@ -72,8 +72,14 @@ func TestRangedMap(t *testing.T) {
return M
}
// K is alias for KeyRange
type K = KeyRange
// K creates [lo,hi) KeyRange
K := func(lo,hi Key) KeyRange {
hi_ := hi
if hi_ != noo {
hi_--
}
return KeyRange{lo, hi_}
}
// y, n alias true/false
const y, n = true, false
......@@ -90,7 +96,7 @@ func TestRangedMap(t *testing.T) {
testv := []testEntry{
E(
M(1,2,a, 2,3,b), // A
K{1,3}, // B
K(1,3), // B
M(1,3,x), // Set
M(), // Del
y), // Has
......
......@@ -288,8 +288,33 @@ func (M *_RangedMap_str) HasRange(r KeyRange) (yes bool) {
return false
}
// all keys from r are in M if r ∈ [ilo] XXX not in case of different values
return (M.entryv[ilo].Lo <= r.Lo && r.Hi_ <= M.entryv[ilo].Hi_)
lo := r.Lo
for {
e := M.entryv[ilo]
debugf_RangedMap_str("\te: %s\ttocheck: %s\n", e, KeyRange{lo, r.Hi_})
if lo < e.Lo {
return false // hole in coverage
}
if r.Hi_ <= e.Hi_ {
return true // full coverage
}
lo = e.Hi_
if lo < KeyMax {
lo++
}
ilo++
if ilo == l {
return false // r's right not fully covered
}
}
// // all keys from r are in M if r ∈ [ilo] XXX not in case of different values
// return (M.entryv[ilo].Lo <= r.Lo && r.Hi_ <= M.entryv[ilo].Hi_)
}
......
......@@ -288,8 +288,33 @@ func (M *_RangedMap_void) HasRange(r KeyRange) (yes bool) {
return false
}
// all keys from r are in M if r ∈ [ilo] XXX not in case of different values
return (M.entryv[ilo].Lo <= r.Lo && r.Hi_ <= M.entryv[ilo].Hi_)
lo := r.Lo
for {
e := M.entryv[ilo]
debugf_RangedMap_void("\te: %s\ttocheck: %s\n", e, KeyRange{lo, r.Hi_})
if lo < e.Lo {
return false // hole in coverage
}
if r.Hi_ <= e.Hi_ {
return true // full coverage
}
lo = e.Hi_
if lo < KeyMax {
lo++
}
ilo++
if ilo == l {
return false // r's right not fully covered
}
}
// // all keys from r are in M if r ∈ [ilo] XXX not in case of different values
// return (M.entryv[ilo].Lo <= r.Lo && r.Hi_ <= M.entryv[ilo].Hi_)
}
......
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