Iterator 添加GetNode函数, 修改SeNode缺字母SetNode

This commit is contained in:
huangsimin 2019-07-18 14:25:15 +08:00
parent c26cc4dfe3
commit ff2ec652c9
9 changed files with 39 additions and 7 deletions

View File

@ -30,7 +30,11 @@ func NewIteratorWithCap(n *Node, cap int) *Iterator {
return iter
}
func (iter *Iterator) SeNode(n *Node) {
func (iter *Iterator) GetNode() *Node {
return iter.cur
}
func (iter *Iterator) SetNode(n *Node) {
iter.up = n
iter.dir = 0
iter.tstack.Clear()
@ -61,7 +65,7 @@ func (iter *Iterator) Right() bool {
func (iter *Iterator) GetNext(cur *Node, idx int) *Node {
// iter := NewIterator(cur)
iter.SeNode(cur)
iter.SetNode(cur)
iter.curPushNextStack(iter.up)
iter.up = iter.getNextUp(iter.up)
@ -120,7 +124,7 @@ func (iter *Iterator) Next() (result bool) {
func (iter *Iterator) GetPrev(cur *Node, idx int) *Node {
// iter := NewIterator(cur)
iter.SeNode(cur)
iter.SetNode(cur)
iter.curPushPrevStack(iter.up)
iter.up = iter.getPrevUp(iter.up)

View File

@ -30,7 +30,11 @@ func NewIteratorWithCap(n *Node, cap int) *Iterator {
return iter
}
func (iter *Iterator) SeNode(n *Node) {
func (iter *Iterator) GetNode() *Node {
return iter.cur
}
func (iter *Iterator) SetNode(n *Node) {
iter.up = n
iter.dir = 0
iter.tstack.Clear()
@ -61,7 +65,7 @@ func (iter *Iterator) Right() bool {
func (iter *Iterator) GetNext(cur *Node, idx int) *Node {
// iter := NewIterator(cur)
iter.SeNode(cur)
iter.SetNode(cur)
iter.curPushNextStack(iter.up)
iter.up = iter.getNextUp(iter.up)
@ -120,7 +124,7 @@ func (iter *Iterator) Next() (result bool) {
func (iter *Iterator) GetPrev(cur *Node, idx int) *Node {
// iter := NewIterator(cur)
iter.SeNode(cur)
iter.SetNode(cur)
iter.curPushPrevStack(iter.up)
iter.up = iter.getPrevUp(iter.up)

View File

@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"github.com/474420502/focus/avldup"
"github.com/474420502/focus/tree/avldup"
"github.com/474420502/focus/compare"
)

View File

@ -30,6 +30,10 @@ func NewIteratorWithCap(n *Node, cap int) *Iterator {
return iter
}
func (iter *Iterator) GetNode() *Node {
return iter.cur
}
func (iter *Iterator) SetNode(n *Node) {
iter.up = n
iter.dir = 0

View File

@ -30,6 +30,10 @@ func NewIteratorWithCap(n *Node, cap int) *Iterator {
return iter
}
func (iter *Iterator) GetNode() *Node {
return iter.cur
}
func (iter *Iterator) SetNode(n *Node) {
iter.up = n
iter.dir = 0

View File

@ -30,6 +30,10 @@ func NewIteratorWithCap(n *Node, cap int) *Iterator {
return iter
}
func (iter *Iterator) GetNode() *Node {
return iter.cur
}
func (iter *Iterator) SetNode(n *Node) {
iter.up = n
iter.dir = 0

View File

@ -30,6 +30,10 @@ func NewIteratorWithCap(n *Node, cap int) *Iterator {
return iter
}
func (iter *Iterator) GetNode() *Node {
return iter.cur
}
func (iter *Iterator) SetNode(n *Node) {
iter.up = n
iter.dir = 0

View File

@ -30,6 +30,10 @@ func NewIteratorWithCap(n *Node, cap int) *Iterator {
return iter
}
func (iter *Iterator) GetNode() *Node {
return iter.cur
}
func (iter *Iterator) SetNode(n *Node) {
iter.up = n
iter.dir = 0

View File

@ -30,6 +30,10 @@ func NewIteratorWithCap(n *Node, cap int) *Iterator {
return iter
}
func (iter *Iterator) GetNode() *Node {
return iter.cur
}
func (iter *Iterator) SetNode(n *Node) {
iter.up = n
iter.dir = 0