class Quartz::BinaryHeap(T)

Overview

Event set implemented as an array-based heap.

Each inserted elements is given a certain priority, based on the result of the comparison. This is a min-heap, which means retrieving an element will always return the one with the highest priority.

To avoid O(n) complexity when deleting an arbitrary element, a map is used to store indices for each element in the event set.

Defined in:

quartz/priority_queues/binary_heap.cr

Constructors

Instance Method Summary

Instance methods inherited from class Quartz::PriorityQueue(T)

clear clear, delete(priority : Duration, value : T) : T? delete, empty? : Bool empty?, next_priority : Duration next_priority, peek : T peek, peek? : T? peek?, pop : T pop, pop_imminents(&) pop_imminents, push(priority : Duration, value : T) push, size : Int size

Constructor methods inherited from class Quartz::PriorityQueue(T)

new(priority_queue : Symbol, &comparator : Duration, Duration, Bool -> Int32) : self
new(&)
new

Instance methods inherited from class Reference

==(other : Quartz::Any) ==

Instance methods inherited from class Object

===(other : Quartz::Any) ===

Constructor Detail

def self.new(initial_capacity : Int, &comparator : Duration, Duration, Bool -> Int32) #

[View source]
def self.new(&comparator : Duration, Duration, Bool -> Int32) #

Creates a new empty BinaryHeap.


[View source]

Instance Method Detail

def ==(other) : Bool #
Description copied from class Reference

Returns false (other can only be a Value here).


[View source]
def ==(other : BinaryHeap) : Bool #

[View source]
def clear #

[View source]
def delete(priority : Duration, event : T) : T? #

[View source]
def empty? : Bool #

[View source]
def heapify! #

[View source]
def inspect(io) #

[View source]
def next_priority : Duration #

[View source]
def next_priority(&) #

[View source]
def peek : T #

[View source]
def peek(&) #

[View source]
def peek? : T? #

[View source]
def pop : T #

[View source]
def push(priority : Duration, value : T) : self #

[View source]
def size : Int32 #

Returns the number of elements in the heap.


[View source]
def to_a : Array(Tuple(Duration, T)) #

[View source]
def to_slice : Slice(Tuple(Duration, T)) #

[View source]