# frozen_string_literal: true

require 'tsort'

# Hash that topologically sorts itself upon insertion of a key
class TsortableHash < Hash
  include TSort

  alias tsort_each_node each_key
  def tsort_each_child(node, &block)
    fetch(node).each(&block)
  end
end
