class Algorithmable::Sort::BinaryHeap
Public Class Methods
new(collection = [])
click to toggle source
# File lib/algorithmable/sort/binary_heap.rb, line 10 def initialize(collection = []) @heap = new_min_priority_queue collection end
sort(collection)
click to toggle source
# File lib/algorithmable/sort/binary_heap.rb, line 6 def self.sort(collection) new(collection).sort end
Public Instance Methods
sort()
click to toggle source
# File lib/algorithmable/sort/binary_heap.rb, line 14 def sort [].tap do |result| result << @heap.dequeue until @heap.empty? end end