class TreeMap::NodeIterator

in-order traversal of nodes in tree

Public Class Methods

new(next_node) click to toggle source
# File lib/treemap/tree_map.rb, line 625
def initialize(next_node)
  @next_node = next_node
  @last_node = nil
end

Public Instance Methods

has_next?() click to toggle source
# File lib/treemap/tree_map.rb, line 630
def has_next?
  !!@next_node
end
step_backward() click to toggle source
# File lib/treemap/tree_map.rb, line 642
def step_backward
  if @next_node
    @last_node = @next_node
    @next_node = @next_node.prev_node
    @last_node
  end
end
step_forward() click to toggle source
# File lib/treemap/tree_map.rb, line 634
def step_forward
  if @next_node
    @last_node = @next_node
    @next_node = @next_node.next_node
    @last_node
  end
end