Commit 1c847f19 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 21b2dc8f
......@@ -68,11 +68,6 @@ func (M *RangedMap) Get(k Key) VALUE {
// HasRange returns whether all keys from range r belong to the map.
func (M *RangedMap) HasRange(r KeyRange) bool {
panic("TODO") // XXX
}
// Get_ is comma-ok version of Get.
func (M *RangedMap) Get_(k Key) (VALUE, bool) {
panic("TODO") // XXX
......@@ -84,7 +79,7 @@ func (M *RangedMap) Get_(k Key) (VALUE, bool) {
// SetRange changes M to map key range r to value v.
func (M *RangedMap) SetRange(r KeyRange, v VALUE) {
e := mapEntry{r,v}
if traceRangeSet {
if traceRangeMap {
fmt.Printf("\n\nSetRange:\n")
fmt.Printf(" M: %s\n", M)
fmt.Printf(" e: %s\n", e)
......@@ -169,7 +164,7 @@ func (M *RangedMap) SetRange(r KeyRange, v VALUE) {
// DelRange removes range r from the map.
func (M *RangedMap) DelRange(r KeyRange) {
if traceRangeSet {
if traceRangeMap {
fmt.Printf("\n\nDelRange:\n")
fmt.Printf(" M: %s\n", M)
fmt.Printf(" r: %s\n", r)
......@@ -237,23 +232,23 @@ func (M *RangedMap) DelRange(r KeyRange) {
// done
}
// HasRange returns whether all keys from range r belong to the set.
func (S *RangedMap) HasRange(r KeyRange) (yes bool) {
if traceRangeSet {
// HasRange returns whether all keys from range r belong to the map.
func (M *RangedMap) HasRange(r KeyRange) (yes bool) {
if traceRangeMap {
fmt.Printf("\n\nHasRange:\n")
fmt.Printf(" S: %s\n", S)
fmt.Printf(" M: %s\n", M)
fmt.Printf(" r: %s\n", r)
defer func() {
fmt.Printf("->·: %v\n", yes)
}()
}
S.verify()
M.verify()
// find first ilo: r.lo < [ilo].hi
l := len(S.rangev)
l := len(M.rangev)
ilo := sort.Search(l, func(i int) bool {
return r.Lo <= S.rangev[i].Hi_
return r.Lo <= M.rangev[i].Hi_
})
debugfRMap("\tilo: %d\n", ilo)
......@@ -261,8 +256,8 @@ func (S *RangedMap) HasRange(r KeyRange) (yes bool) {
return false
}
// all keys from r are in S if r [ilo]
return (S.rangev[ilo].Lo <= r.Lo && r.Hi_ <= S.rangev[ilo].Hi_)
// all keys from r are in M if r [ilo] XXX not in case of different values
return (M.rangev[ilo].Lo <= r.Lo && r.Hi_ <= M.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