Commit 0ac4fdc7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent fecb9373
...@@ -317,7 +317,7 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) { ...@@ -317,7 +317,7 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
// check if we can do the delete nearby previous change // check if we can do the delete nearby previous change
i, ok := t.hitFind(k) i, ok := t.hitFind(k)
if i >= 0 { if i >= 0 {
//dbg("hit found\t-> %d, %v", i, ok) dbg("hit found\t-> %d, %v", i, ok)
dd := t.hitD dd := t.hitD
switch { switch {
...@@ -325,7 +325,7 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) { ...@@ -325,7 +325,7 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
//dbg("ok'") //dbg("ok'")
if i >= dd.c { if i >= dd.c {
// tried to delete element past max k in hitD // tried to delete element past max k in hitD
i = dd.c - 1 i--
} }
t.hitDi = i t.hitDi = i
return false return false
...@@ -423,9 +423,13 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) { ...@@ -423,9 +423,13 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
//t.hitPKmax = hitPKmax //t.hitPKmax = hitPKmax
if !ok { if !ok {
dbg("!ok") //dbg("!ok")
t.hitD = x t.hitD = x
t.hitDi = i // XXX vs > h ? if i >= x.c {
// tried to delete element past max k in hitD
i--
}
t.hitDi = i
return false return false
} }
...@@ -438,7 +442,7 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) { ...@@ -438,7 +442,7 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
//dbg("underflow") //dbg("underflow")
t.underflow(p, x, pi) t.underflow(p, x, pi)
} else if t.c == 0 { } else if t.c == 0 {
dbg("clear") //dbg("clear")
t.Clear() t.Clear()
} }
} }
...@@ -527,6 +531,8 @@ func (t *Tree) find2(d *d, k interface{} /*K*/, l, h int) (i int, ok bool) { ...@@ -527,6 +531,8 @@ func (t *Tree) find2(d *d, k interface{} /*K*/, l, h int) (i int, ok bool) {
// - i: index corresponding to data entry in t.hitD with min(k' : k <= k') // - i: index corresponding to data entry in t.hitD with min(k' : k <= k')
// - ok: whether k' == k // - ok: whether k' == k
func (t *Tree) hitFind(k interface{} /*K*/) (i int, ok bool) { func (t *Tree) hitFind(k interface{} /*K*/) (i int, ok bool) {
return -1, false // XXX for testing how hit{Kmin,Kmax} are computed on all test keys
hit := t.hitD hit := t.hitD
if hit == nil { if hit == nil {
return -1, false return -1, false
...@@ -728,7 +734,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) { ...@@ -728,7 +734,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
// check if we can do the update nearby previous change // check if we can do the update nearby previous change
i, ok := t.hitFind(k) i, ok := t.hitFind(k)
if i >= 0 { if i >= 0 {
//dbg("hit found\t-> %d, %v", i, ok) dbg("hit found\t-> %d, %v", i, ok)
dd := t.hitD dd := t.hitD
switch { switch {
......
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