添加了树的接口
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user