Prioqueue v0.2.7 Prioqueue.Implementations.SkewHeap View Source

An implementation of a Priority Queue built on top of a Skew Heap.

A Skew Heap is very simple, which means that this implementation is also quite concise: All operations are built on top of a 'combine' procedure.

To improve efficiency, the internal heap is stored as tuples representing tree nodes (rather than structs representing tree nodes)

More information about Skew Heaps can be found in Issue #16 of the Monad.Reader.

Link to this section Summary

Functions

A variant of reduce that accepts anything that is Combinable as second argument. This Combinable will determine what the empty value and the combining operation will be.

Converts the reducable into a list, by building up a list from all elements, and in the end reversing it.

Link to this section Functions

Link to this function

combine(pqueue1, skew_heap) View Source

Callback implementation for FunLand.Semicombinable.combine/2.

A variant of reduce that accepts anything that is Combinable as second argument. This Combinable will determine what the empty value and the combining operation will be.

Pass in the combinable module name to start with empty as accumulator, or the combinable as struct to use that as starting accumulator.

Link to this function

reduce(prioqueue, acc, fun) View Source

Callback implementation for FunLand.Reducable.reduce/3.

Converts the reducable into a list, by building up a list from all elements, and in the end reversing it.

This is an automatic function implementation, made possible because Prioqueue.Implementations.SkewHeap implements the FunLand.Reducable behaviour.