brew/Library/Homebrew/cask/lib/hbc/topological_hash.rb

15 lines
243 B
Ruby
Raw Normal View History

2016-08-18 22:11:42 +03:00
require "tsort"
# a basic topologically sortable hashmap
2016-09-24 13:52:43 +02:00
module Hbc
class TopologicalHash < Hash
include TSort
2016-08-18 22:11:42 +03:00
2016-09-24 13:52:43 +02:00
alias tsort_each_node each_key
2016-08-18 22:11:42 +03:00
2016-09-24 13:52:43 +02:00
def tsort_each_child(node, &block)
fetch(node).each(&block)
end
2016-08-18 22:11:42 +03:00
end
end