添加了树的接口

This commit is contained in:
2019-07-29 02:18:22 +08:00
parent 4a58bd283e
commit 3ade1566c2
10 changed files with 94 additions and 21 deletions

View File

@@ -1,8 +1,10 @@
package vbt
import (
"github.com/474420502/focus/compare"
"github.com/davecgh/go-spew/spew"
"github.com/474420502/focus/compare"
"github.com/474420502/focus/tree"
)
type Node struct {
@@ -31,6 +33,10 @@ type Tree struct {
iter *Iterator
}
func assertImplementation() {
var _ tree.IBSTree = (*Tree)(nil)
}
func New(Compare compare.Compare) *Tree {
return &Tree{Compare: Compare, iter: NewIteratorWithCap(nil, 16)}
}
@@ -231,6 +237,11 @@ func (tree *Tree) Remove(key interface{}) (interface{}, bool) {
return nil, false
}
func (tree *Tree) Clear() {
tree.root = nil
tree.iter = NewIteratorWithCap(nil, 16)
}
// Values 返回先序遍历的值
func (tree *Tree) Values() []interface{} {
mszie := 0