Class: RDG::Tree::RGL::PostOrderIterator
- Inherits:
-
Object
- Object
- RDG::Tree::RGL::PostOrderIterator
- Includes:
- RGL::GraphIterator
- Defined in:
- lib/rdg/tree/rgl/post_order_iterator.rb
Instance Method Summary collapse
- #at_beginning? ⇒ Boolean
- #at_end? ⇒ Boolean
- #basic_backward ⇒ Object
- #basic_forward ⇒ Object
-
#initialize(tree, root = tree.first) ⇒ PostOrderIterator
constructor
A new instance of PostOrderIterator.
- #set_to_begin ⇒ Object
Constructor Details
#initialize(tree, root = tree.first) ⇒ PostOrderIterator
Returns a new instance of PostOrderIterator.
9 10 11 12 13 |
# File 'lib/rdg/tree/rgl/post_order_iterator.rb', line 9 def initialize(tree, root = tree.first) super(tree) @root = root set_to_begin end |
Instance Method Details
#at_beginning? ⇒ Boolean
22 23 24 |
# File 'lib/rdg/tree/rgl/post_order_iterator.rb', line 22 def at_beginning? @current == @start end |
#at_end? ⇒ Boolean
26 27 28 |
# File 'lib/rdg/tree/rgl/post_order_iterator.rb', line 26 def at_end? visited?(@root) end |
#basic_backward ⇒ Object
36 37 38 39 40 |
# File 'lib/rdg/tree/rgl/post_order_iterator.rb', line 36 def basic_backward @current = ascend(@current) unvisit(@current) @current end |
#basic_forward ⇒ Object
30 31 32 33 34 |
# File 'lib/rdg/tree/rgl/post_order_iterator.rb', line 30 def basic_forward @current = descend(@current) visit(@current) @current end |
#set_to_begin ⇒ Object
15 16 17 18 19 20 |
# File 'lib/rdg/tree/rgl/post_order_iterator.rb', line 15 def set_to_begin @visited = Hash.new(false) @stack = [] @start = descend(@root) @current = @start end |