Commit 2ca0cdc7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent bb14198c
......@@ -235,8 +235,31 @@ func (S *RangeSet) DelRange(r Range) {
}
// HasRange returns whether all keys from Range r belong to the set.
func (S *RangeSet) HasRange(r Range) bool {
panic("TODO")
func (S *RangeSet) HasRange(r Range) (yes bool) {
if traceRangeSet {
fmt.Printf("\n\nHasRange:\n")
fmt.Printf(" S: %s\n", S)
fmt.Printf(" r: %s\n", r)
defer func() {
fmt.Printf("->·: %v\n", yes)
}()
}
S.verify()
// find first ilo: r.lo < [ilo].hi
l := len(S.rangev)
ilo := sort.Search(l, func(i int) bool {
return r.lo <= S.rangev[i].hi_
})
debugfRSet("\tilo: %d\n", ilo)
if ilo == l { // not found
return false
}
// all keys from r are in S if r ∈ [ilo]
return r.hi_ <= S.rangev[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