class PriorityQueue

Public Class Methods

new() click to toggle source
# File lib/rbutils/graph/priorityqueue.rb, line 2
def initialize
  @queue = {}
end

Public Instance Methods

any?() click to toggle source
# File lib/rbutils/graph/priorityqueue.rb, line 6
def any?
  return @queue.any?
end
insert(key, value) click to toggle source
# File lib/rbutils/graph/priorityqueue.rb, line 10
def insert(key, value)
  @queue[key] = value
  @queue.sort_by {|_key, value| value }
end
remove_max() click to toggle source
# File lib/rbutils/graph/priorityqueue.rb, line 15
def remove_max
  @queue.shift.last
end
remove_min() click to toggle source
# File lib/rbutils/graph/priorityqueue.rb, line 19
def remove_min
  @queue.shift.first
end