class Shortest::Path::PriorityQueue

@see branch14.org/snippets/a_star_in_ruby.html

Public Class Methods

new() click to toggle source
# File lib/shortest/path/astar.rb, line 7
def initialize; @list = [] end

Public Instance Methods

<<(pritem) click to toggle source
# File lib/shortest/path/astar.rb, line 15
def <<(pritem); add(*pritem) end
add(priority, item) click to toggle source
# File lib/shortest/path/astar.rb, line 9
def add(priority, item)
  @list << [priority, @list.length, item]
  @list.sort!
  self
end
empty?() click to toggle source
# File lib/shortest/path/astar.rb, line 17
def empty?; @list.empty? end
next() click to toggle source
# File lib/shortest/path/astar.rb, line 16
def next; @list.shift[2] end