class Priority::MaxHeap(K, V)
- Priority::MaxHeap(K, V)
- Priority::Heap(K, V)
- Reference
- Object
Overview
A MaxHeap is a heap where the items are returned in descending order of key value.
Defined in:
priority-queue/max_heap.crConstructors
-
.new
call-seq: MaxHeap.new(ary) -> new_heap
Instance methods inherited from class Priority::Heap(K, V)
<<(key)
<<,
change_key(key, new_key, delete = false)
change_key,
clear
clear,
delete(key)
delete,
empty?
empty?,
key?(key)
key?,
merge!(otherheap)
merge!,
next
next,
next!
next!,
next_key
next_key,
next_node
next_node,
pop
pop,
push(key : K, value : V = key)
push,
size : Int32
size,
stored
stored
Constructor methods inherited from class Priority::Heap(K, V)
newnew(&compare_fn : Proc(K, K, Bool)) new
Constructor Detail
def self.new
#
call-seq: MaxHeap.new(ary) -> new_heap
Creates a new MaxHeap with an optional array parameter of items to insert into the heap. A MaxHeap is created by calling Heap.new { |x, y| (x <=> y) == 1 }, so this is a convenience class.
maxheap = MaxHeap.new([1, 2, 3, 4])
maxheap.pop #=> 4
maxheap.pop #=> 3