奇怪的错误

This commit is contained in:
huangsimin 2019-04-03 18:24:05 +08:00
parent f0f16d7516
commit 3d1be547ca
2 changed files with 10 additions and 3 deletions

View File

@ -153,7 +153,9 @@ func (tree *Tree) GetRange(k1, k2 interface{}) (result []interface{}) {
result = make([]interface{}, 0, 16)
iter := NewIterator(min)
// iter := NewIterator(min)
tree.iter.SetNode(min)
iter := tree.iter
for iter.Next() {
result = append(result, iter.Value())
if iter.cur == max {
@ -228,7 +230,9 @@ func (tree *Tree) getArountNode(key interface{}) (result [3]*Node) {
n = n.children[1]
lastc = c
case 0:
iter := NewIterator(n)
// iter := NewIterator(n)
tree.iter.SetNode(n)
iter := tree.iter
iter.Prev()
for iter.Prev() {
if tree.Compare(iter.cur.value, n.value) == 0 {

View File

@ -25,16 +25,19 @@ func TestPush(t *testing.T) {
t.Error(s.String(), " size ", s.size)
}
var l []int
for i := 0; i < 10; i++ {
v := randomdata.Number(0, 10)
s.Push(v)
l = append(l, v)
}
for i := -1; i < 11; i++ {
v, ok := s.Get(i)
t.Error(v, ok)
}
t.Error(l)
}
func BenchmarkGet(b *testing.B) {