Sha256: 218ea24cd47ffcec97a319b30bd5ba1c8cb532fa1dcddb092bc521f2c7d6611a
Contents?: true
Size: 560 Bytes
Versions: 2
Compression:
Stored size: 560 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) end def tsort_each_node(&block) @table.keys.each(&block) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ykutils-0.1.10 | lib/ykutils/treemanager.rb |
ykutils-0.1.8 | lib/ykutils/treemanager.rb |