From ff2ec652c9682d213767ac0cf0cf7848966168ee Mon Sep 17 00:00:00 2001 From: huangsimin Date: Thu, 18 Jul 2019 14:25:15 +0800 Subject: [PATCH] =?UTF-8?q?Iterator=20=E6=B7=BB=E5=8A=A0GetNode=E5=87=BD?= =?UTF-8?q?=E6=95=B0,=20=E4=BF=AE=E6=94=B9SeNode=E7=BC=BA=E5=AD=97?= =?UTF-8?q?=E6=AF=8DSetNode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- priority_queue/iterator.go | 10 +++++++--- priority_queuekey/iterator.go | 10 +++++++--- set/treeset/treeset.go | 2 +- tree/avl/iterator.go | 4 ++++ tree/avldup/iterator.go | 4 ++++ tree/avlkey/iterator.go | 4 ++++ tree/avlkeydup/iterator.go | 4 ++++ tree/vbt/iterator.go | 4 ++++ tree/vbtkey/iterator.go | 4 ++++ 9 files changed, 39 insertions(+), 7 deletions(-) diff --git a/priority_queue/iterator.go b/priority_queue/iterator.go index a443d4b..41dcfee 100644 --- a/priority_queue/iterator.go +++ b/priority_queue/iterator.go @@ -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) diff --git a/priority_queuekey/iterator.go b/priority_queuekey/iterator.go index bf8952a..4481862 100644 --- a/priority_queuekey/iterator.go +++ b/priority_queuekey/iterator.go @@ -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) diff --git a/set/treeset/treeset.go b/set/treeset/treeset.go index 5149753..af76bf3 100644 --- a/set/treeset/treeset.go +++ b/set/treeset/treeset.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/474420502/focus/avldup" + "github.com/474420502/focus/tree/avldup" "github.com/474420502/focus/compare" ) diff --git a/tree/avl/iterator.go b/tree/avl/iterator.go index 5fdc877..6436a96 100644 --- a/tree/avl/iterator.go +++ b/tree/avl/iterator.go @@ -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 diff --git a/tree/avldup/iterator.go b/tree/avldup/iterator.go index cd86da2..1ef37ea 100644 --- a/tree/avldup/iterator.go +++ b/tree/avldup/iterator.go @@ -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 diff --git a/tree/avlkey/iterator.go b/tree/avlkey/iterator.go index fbe3ca4..1de0bc2 100644 --- a/tree/avlkey/iterator.go +++ b/tree/avlkey/iterator.go @@ -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 diff --git a/tree/avlkeydup/iterator.go b/tree/avlkeydup/iterator.go index 9c8c815..4369589 100644 --- a/tree/avlkeydup/iterator.go +++ b/tree/avlkeydup/iterator.go @@ -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 diff --git a/tree/vbt/iterator.go b/tree/vbt/iterator.go index 8e3d6a6..3a09be1 100644 --- a/tree/vbt/iterator.go +++ b/tree/vbt/iterator.go @@ -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 diff --git a/tree/vbtkey/iterator.go b/tree/vbtkey/iterator.go index 6a96906..2d7acc4 100644 --- a/tree/vbtkey/iterator.go +++ b/tree/vbtkey/iterator.go @@ -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