Commit 6397d666 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent dc6556cd
...@@ -226,15 +226,15 @@ func TestSetGet1(t *testing.T) { ...@@ -226,15 +226,15 @@ func TestSetGet1(t *testing.T) {
//const N = 21 //const N = 21
const N = 41 const N = 41
//for _, x := range []int{0, -1, 0x555555, 0xaaaaaa, 0x333333, 0xcccccc, 0x314159} { //for _, x := range []int{0, -1, 0x555555, 0xaaaaaa, 0x333333, 0xcccccc, 0x314159} {
//for _, x := range []int{0x314159} { for _, x := range []int{0x314159} {
for _, x := range []int{0} { //for _, x := range []int{0} {
r := TreeNew(cmp) r := TreeNew(cmp)
set := r.Set set := r.Set
a := make([]int, N) a := make([]int, N)
for i := range a { for i := range a {
a[i] = (i ^ x) << 1 a[i] = (i ^ x) << 1
} }
dbg("", a) //dbg("", a)
for i, k := range a { for i, k := range a {
set(k, k^x) set(k, k^x)
if g, e := r.Len(), i+1; g != e { if g, e := r.Len(), i+1; g != e {
......
...@@ -634,13 +634,13 @@ func (t *Tree) SeekLast() (e *Enumerator, err error) { ...@@ -634,13 +634,13 @@ func (t *Tree) SeekLast() (e *Enumerator, err error) {
// Set sets the value associated with k. // Set sets the value associated with k.
func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) { func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
dbg("--- PRE Set(%v, %v)\t(%v @%d, %v/%v, %v @%d)\n%s", k, v, t.hit, t.hitIdx, t.hitMaxKInf, t.hitMaxK, t.hitP, t.hitPi, t.dump()) //dbg("--- PRE Set(%v, %v)\t(%v @%d, %v/%v, %v @%d)\n%s", k, v, t.hit, t.hitIdx, t.hitMaxKInf, t.hitMaxK, t.hitP, t.hitPi, t.dump())
defer func() { //defer func() {
//if r := recover(); r != nil { // //if r := recover(); r != nil {
// panic(r) // // panic(r)
//} // //}
dbg("--- POST\n%s\n====\n", t.dump()) // dbg("--- POST\n%s\n====\n", t.dump())
}() //}()
// 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)
...@@ -651,13 +651,13 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) { ...@@ -651,13 +651,13 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
switch { switch {
case ok: case ok:
dbg("ok'") //dbg("ok'")
dd.d[i].v = v dd.d[i].v = v
t.hitIdx = i t.hitIdx = i
return return
case dd.c < 2*kd: case dd.c < 2*kd:
dbg("insert'") //dbg("insert'")
t.insert(dd, i, k, v) t.insert(dd, i, k, v)
return return
...@@ -716,7 +716,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) { ...@@ -716,7 +716,7 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
// data page found - perform the update // data page found - perform the update
switch { switch {
case ok: case ok:
dbg("ok") //dbg("ok")
x.d[i].v = v x.d[i].v = v
t.hit, t.hitIdx = x, i t.hit, t.hitIdx = x, i
t.hitP, t.hitPi = p, pi t.hitP, t.hitPi = p, pi
...@@ -724,14 +724,14 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) { ...@@ -724,14 +724,14 @@ func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) {
t.hitMaxKInf = maxKInf t.hitMaxKInf = maxKInf
case x.c < 2*kd: case x.c < 2*kd:
dbg("insert") //dbg("insert")
t.insert(x, i, k, v) t.insert(x, i, k, v)
t.hitP, t.hitPi = p, pi t.hitP, t.hitPi = p, pi
t.hitMaxK = maxK t.hitMaxK = maxK
t.hitMaxKInf = maxKInf t.hitMaxKInf = maxKInf
default: default:
dbg("overflow") //dbg("overflow")
t.overflow(p, x, pi, i, k, v) t.overflow(p, x, pi, i, k, v)
t.hitMaxK = maxK t.hitMaxK = maxK
t.hitMaxKInf = maxKInf t.hitMaxKInf = maxKInf
......
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