Class: Containers::Heap
Instance Method Summary collapse
Instance Method Details
#each(*args, &block) ⇒ Object
11 12 13 |
# File 'lib/algorithms/containers/heap.rb', line 11 def each(*args, &block) to_a.each(*args, &block) end |
#to_a ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/algorithms/containers/heap.rb', line 3 def to_a ret = @stored.to_a ret.sort! { |a,b| (@compare_fn[a[0],b[0]] ? -1 : 1) } ret.map! { |k,v| v.map { |f| f.value } } ret.flatten! ret end |