Sha256: eab2225be4c27fc0b3e1bf934acc9a14348945235b6750e3a826de612ab3a12a
Contents?: true
Size: 599 Bytes
Versions: 3
Compression:
Stored size: 599 Bytes
Contents
require "tsort" module Ykytils class TreeManager include TSort def initialize @table = {} end def add(parent_name, name) if parent_name parent = @table[parent_name] if parent @table[parent_name] << name else @table[parent_name] = [name] end else @table[name] = [] end end def tsort_each_child(node, &block) ary = @table[node] ary.each(&block) if ary end def tsort_each_node(&block) @table.keys.each(&block) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ykutils-0.1.4 | lib/ykutils/treemanager.rb |
ykutils-0.1.3 | lib/ykutils/treemanager.rb |
ykutils-0.1.1 | lib/ykutils/treemanager.rb |