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

.

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