修改lastack清空时候不正确的问题
This commit is contained in:
parent
6b1d2a80e9
commit
2333e08152
|
@ -252,12 +252,12 @@ ALL:
|
|||
}
|
||||
}
|
||||
|
||||
const PutCompartorSize = 300000
|
||||
const CompartorSize = 300000
|
||||
const NumberMax = 60000000
|
||||
|
||||
func BenchmarkIterator(b *testing.B) {
|
||||
avl := New(utils.IntComparator)
|
||||
b.N = PutCompartorSize
|
||||
b.N = CompartorSize
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
v := randomdata.Number(0, NumberMax)
|
||||
|
@ -283,7 +283,7 @@ func BenchmarkIterator(b *testing.B) {
|
|||
|
||||
func BenchmarkGodsIterator(b *testing.B) {
|
||||
avl := avltree.NewWithIntComparator()
|
||||
b.N = PutCompartorSize
|
||||
b.N = CompartorSize
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
v := randomdata.Number(0, NumberMax)
|
||||
|
@ -310,7 +310,7 @@ func BenchmarkGodsIterator(b *testing.B) {
|
|||
func BenchmarkRemove(b *testing.B) {
|
||||
|
||||
avl := New(utils.IntComparator)
|
||||
b.N = PutCompartorSize
|
||||
b.N = CompartorSize
|
||||
|
||||
var l []int
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
@ -329,7 +329,7 @@ func BenchmarkRemove(b *testing.B) {
|
|||
|
||||
func BenchmarkGodsRemove(b *testing.B) {
|
||||
avl := avltree.NewWithIntComparator()
|
||||
b.N = PutCompartorSize
|
||||
b.N = CompartorSize
|
||||
|
||||
var l []int
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
@ -349,7 +349,7 @@ func BenchmarkGodsRemove(b *testing.B) {
|
|||
func BenchmarkGet(b *testing.B) {
|
||||
avl := New(utils.IntComparator)
|
||||
|
||||
b.N = PutCompartorSize
|
||||
b.N = CompartorSize
|
||||
for i := 0; i < b.N/2; i++ {
|
||||
avl.Put(randomdata.Number(0, NumberMax))
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ func BenchmarkGet(b *testing.B) {
|
|||
func BenchmarkGodsRBGet(b *testing.B) {
|
||||
rb := redblacktree.NewWithIntComparator()
|
||||
|
||||
b.N = PutCompartorSize
|
||||
b.N = CompartorSize
|
||||
for i := 0; i < b.N/2; i++ {
|
||||
rb.Put(randomdata.Number(0, NumberMax), i)
|
||||
}
|
||||
|
@ -379,7 +379,7 @@ func BenchmarkGodsRBGet(b *testing.B) {
|
|||
func BenchmarkGodsAvlGet(b *testing.B) {
|
||||
rb := avltree.NewWithIntComparator()
|
||||
|
||||
b.N = PutCompartorSize
|
||||
b.N = CompartorSize
|
||||
for i := 0; i < b.N/2; i++ {
|
||||
rb.Put(randomdata.Number(0, NumberMax), i)
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ func BenchmarkPut(b *testing.B) {
|
|||
|
||||
b.ResetTimer()
|
||||
b.StartTimer()
|
||||
b.N = PutCompartorSize
|
||||
b.N = CompartorSize
|
||||
for i := 0; i < b.N; i++ {
|
||||
avl.Put(randomdata.Number(0, NumberMax))
|
||||
}
|
||||
|
@ -417,7 +417,7 @@ func BenchmarkGodsRBPut(b *testing.B) {
|
|||
b.ResetTimer()
|
||||
b.StartTimer()
|
||||
|
||||
b.N = PutCompartorSize
|
||||
b.N = CompartorSize
|
||||
for i := 0; i < b.N; i++ {
|
||||
rb.Put(randomdata.Number(0, NumberMax), i)
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ func BenchmarkGodsPut(b *testing.B) {
|
|||
b.ResetTimer()
|
||||
b.StartTimer()
|
||||
|
||||
b.N = PutCompartorSize
|
||||
b.N = CompartorSize
|
||||
for i := 0; i < b.N; i++ {
|
||||
avl.Put(randomdata.Number(0, NumberMax), i)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package avl
|
||||
|
||||
import (
|
||||
"github.com/emirpasic/gods/stacks/arraystack"
|
||||
"474420502.top/eson/structure/lastack"
|
||||
)
|
||||
|
||||
type Iterator struct {
|
||||
|
@ -10,12 +10,12 @@ type Iterator struct {
|
|||
dir int
|
||||
up *Node
|
||||
cur *Node
|
||||
tstack *arraystack.Stack
|
||||
tstack *lastack.Stack
|
||||
// curnext *Node
|
||||
}
|
||||
|
||||
func initIterator(avltree *AVL) *Iterator {
|
||||
iter := &Iterator{op: avltree, tstack: arraystack.New()}
|
||||
iter := &Iterator{op: avltree, tstack: lastack.New()}
|
||||
iter.up = avltree.root
|
||||
return iter
|
||||
}
|
||||
|
|
9
interface.go
Normal file
9
interface.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
package structure
|
||||
|
||||
type IteratorNext interface {
|
||||
Next() bool
|
||||
}
|
||||
|
||||
type IteratorPrev interface {
|
||||
Prev() bool
|
||||
}
|
Loading…
Reference in New Issue
Block a user