class Tree::TreeNode

Public Instance Methods

reverse_depth_first(&blk) click to toggle source
# File lib/stackprofiler/utils.rb, line 3
def reverse_depth_first &blk
  depths = Hash.new {|h, k| h[k] = [] }
  root.each {|n| depths[n.node_depth].push n }
  depths.delete 0
  keys = depths.keys.sort.reverse

  keys.each do |depth|
    nodes = depths[depth]
    nodes.each &blk
  end
end