Class: RoadForest::Utility::ClassRegistry::NameSequence
- Inherits:
-
Object
- Object
- RoadForest::Utility::ClassRegistry::NameSequence
- Includes:
- TSort
- Defined in:
- lib/roadforest/utility/class-registry.rb
Instance Method Summary collapse
- #add(before, after) ⇒ Object
- #exists(node) ⇒ Object
-
#initialize ⇒ NameSequence
constructor
A new instance of NameSequence.
- #tsort_each_child(node, &block) ⇒ Object
- #tsort_each_node(&block) ⇒ Object
Constructor Details
#initialize ⇒ NameSequence
Returns a new instance of NameSequence.
61 62 63 64 65 |
# File 'lib/roadforest/utility/class-registry.rb', line 61 def initialize @nodes = Hash.new do |h,k| h[k] = [] end end |
Instance Method Details
#add(before, after) ⇒ Object
67 68 69 |
# File 'lib/roadforest/utility/class-registry.rb', line 67 def add(before, after) @nodes[before] << after end |
#exists(node) ⇒ Object
71 72 73 |
# File 'lib/roadforest/utility/class-registry.rb', line 71 def exists(node) @nodes[node] ||= [] end |
#tsort_each_child(node, &block) ⇒ Object
79 80 81 |
# File 'lib/roadforest/utility/class-registry.rb', line 79 def tsort_each_child(node, &block) @nodes.fetch(node).each(&block) end |
#tsort_each_node(&block) ⇒ Object
75 76 77 |
# File 'lib/roadforest/utility/class-registry.rb', line 75 def tsort_each_node(&block) @nodes.each_key(&block) end |