Commit 2720e9af authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 90c38231
...@@ -394,11 +394,11 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) { ...@@ -394,11 +394,11 @@ func (t *Tree) Delete(k interface{} /*K*/) (ok bool) {
pi = i pi = i
q = x.x[pi].ch q = x.x[pi].ch
if pi > 0 { // k=-∞ @ pi=-1 if pi > 0 { // k=-∞ @-1
t.hitKmin.set(p.x[pi-1].k) t.hitKmin.set(p.x[pi-1].k)
} }
if pi < p.c { // k=+∞ @ pi=p.c if pi < p.c { // k=+∞ @p.c
t.hitKmax.set(p.x[pi].k) t.hitKmax.set(p.x[pi].k)
} }
...@@ -626,7 +626,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{ ...@@ -626,7 +626,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
t.insert(q, i-1, k, v) t.insert(q, i-1, k, v)
p.x[pi-1].k = q.d[0].k p.x[pi-1].k = q.d[0].k
t.hitKmin.set(q.d[0].k) t.hitKmin.set(q.d[0].k)
t.hitPi = pi // XXX already pre-set this way //t.hitPi = pi already pre-set this way
return return
} }
...@@ -636,7 +636,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{ ...@@ -636,7 +636,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
t.insert(q, i, k, v) t.insert(q, i, k, v)
p.x[pi].k = r.d[0].k p.x[pi].k = r.d[0].k
t.hitKmax.set(r.d[0].k) t.hitKmax.set(r.d[0].k)
t.hitPi = pi // XXX already pre-set this way //t.hitPi = pi already pre-set this way
return return
} }
...@@ -645,7 +645,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{ ...@@ -645,7 +645,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
t.hitKmin.set(k) t.hitKmin.set(k)
t.hitKmax = t.hitPKmax t.hitKmax = t.hitPKmax
if pi+1 < p.c { // means < ∞ if pi+1 < p.c { // k=+∞ @p.c
t.hitKmax.set(p.x[pi+1].k) t.hitKmax.set(p.x[pi+1].k)
} }
t.hitPi = pi + 1 t.hitPi = pi + 1
...@@ -737,6 +737,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) { ...@@ -737,6 +737,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
default: default:
p, pi := t.hitP, t.hitPi p, pi := t.hitP, t.hitPi
if p == nil || p.c <= 2*kx { if p == nil || p.c <= 2*kx {
// XXX note on overflow corrects what
t.overflow(p, dd, pi, i, k, v) t.overflow(p, dd, pi, i, k, v)
return return
} }
...@@ -765,7 +766,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) { ...@@ -765,7 +766,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
} }
if x.c > 2*kx { if x.c > 2*kx {
// NOTE splitX will correct ... XXX do we need this comment ? // NOTE splitX corrects hit Kmin and Kmax as needed
x, i = t.splitX(p, x, pi, i) x, i = t.splitX(p, x, pi, i)
} }
...@@ -776,11 +777,11 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) { ...@@ -776,11 +777,11 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
pi = i pi = i
q = p.x[pi].ch q = p.x[pi].ch
if pi > 0 { // k=-∞ @ pi=-1 if pi > 0 { // k=-∞ @-1
t.hitKmin.set(p.x[pi-1].k) t.hitKmin.set(p.x[pi-1].k)
} }
if pi < p.c { // k=+∞ @ pi=p.c if pi < p.c { // k=+∞ @p.c
t.hitKmax.set(p.x[pi].k) t.hitKmax.set(p.x[pi].k)
} }
...@@ -798,7 +799,8 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) { ...@@ -798,7 +799,8 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
t.insert(x, i, k, v) t.insert(x, i, k, v)
default: default:
// NOTE overflow will correct hit Kmin, Kmax, P and Pi as needed // NOTE overflow corrects hit Kmin, Kmax and Pi as needed
// XXX if split
t.overflow(p, x, pi, i, k, v) t.overflow(p, x, pi, i, k, v)
} }
...@@ -921,21 +923,21 @@ func (t *Tree) split(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} / ...@@ -921,21 +923,21 @@ func (t *Tree) split(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} /
pi = 0 pi = 0
t.r = p t.r = p
t.hitP = p t.hitP = p
t.hitPi = pi
} }
if i > kd { if i > kd {
t.insert(r, i-kd, k, v) t.insert(r, i-kd, k, v)
t.hitKmin.set(p.x[pi].k) t.hitKmin.set(p.x[pi].k)
kmax := t.hitPKmax t.hitKmax := t.hitPKmax
if pi+1 < p.c { if pi+1 < p.c { // k=+∞ @p.c
kmax.set(p.x[pi+1].k) t.hitKmax.set(p.x[pi+1].k)
} }
t.hitKmax = kmax
t.hitPi = pi + 1 t.hitPi = pi + 1
} else { } else {
t.insert(q, i, k, v) t.insert(q, i, k, v)
t.hitKmax.set(r.d[0].k) t.hitKmax.set(r.d[0].k)
t.hitPi = pi // XXX already pre-set so //t.hitPi = pi already pre-set this way
} }
} }
...@@ -962,7 +964,7 @@ func (t *Tree) splitX(p *x, q *x, pi int, i int) (*x, int) { ...@@ -962,7 +964,7 @@ func (t *Tree) splitX(p *x, q *x, pi int, i int) (*x, int) {
i -= kx + 1 i -= kx + 1
t.hitKmin.set(p.x[pi].k) t.hitKmin.set(p.x[pi].k)
t.hitKmax = t.hitPKmax t.hitKmax = t.hitPKmax
if pi+1 < p.c { // means < ∞ if pi+1 < p.c { // k=+∞ @p.c
t.hitKmax.set(p.x[pi+1].k) t.hitKmax.set(p.x[pi+1].k)
} }
} else { } else {
......
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