Class: BFS
- Inherits:
-
Object
- Object
- BFS
- Defined in:
- lib/rsearch/bfs.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ BFS
constructor
A new instance of BFS.
- #method_missing(meth, *args, &block) ⇒ Object
Constructor Details
#initialize(options) ⇒ BFS
Returns a new instance of BFS.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rsearch/bfs.rb', line 5 def initialize() queue = [] marked = Set.new marked << [:start] scheduler = Proc.new do |states| states.each do |state| if !marked.include?(state) queue << state marked << state end end queue.shift end @search = Search.new(start: [:start], generator: [:generator], scheduler: scheduler) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
24 25 26 |
# File 'lib/rsearch/bfs.rb', line 24 def method_missing(meth, *args, &block) @search.send(meth, *args, &block) end |