class PriorityDequeue(T)

Included Modules

Defined in:

priority_dequeue.cr

Constant Summary

VERSION = "0.1.0"

Constructors

Instance Method Summary

Constructor Detail

def self.new(cap : UInt32 = 0, compare_fn : T, T -> Int32 = ->(a : T, b : T) do a <=> b end) #

[View source]

Instance Method Detail

def <<(elem : T) #

Add a new element, maintaining priority.


[View source]
def add(elem : T) #

Add a new element, maintaining priority.


[View source]
def cap : UInt32 #

[View source]
def del_at(index : UInt32) : T #

Delete and return element at index. Indices are in the same order as iterator, which is not necessarily priority order.


[View source]
def dump(io : IO) #

[View source]
def ensure_total_capacity(new_capacity : UInt32) #

Ensure that the dequeue can fit at least new_capacity items.


[View source]
def ensure_unused_capacity(additional_count : UInt32) #

Ensure that the dequeue can fit at least additional_count more items.


[View source]
def peek_max : T | Nil #

Look at the largest element in the dequeue. Returns nil if empty


[View source]
def peek_min : T | Nil #

Look at the smallest element in the dequeue. Returns nil if empty.


[View source]
def pop_max : T | Nil #

Pop the largest element from the dequeue. Returns nil if empty.


[View source]
def pop_min : T | Nil #

Pop the smallest element from the dequeue. Returns nil if empty.


[View source]
def push(elem : T) #

Add a new element, maintaining priority.


[View source]
def size : UInt32 #
Description copied from module Indexable(T)

Returns the number of elements in this container.


[View source]
def unsafe_fetch(index) : T #

[View source]
def update(old_elem : T, new_elem : T) #

[View source]