pheap

Pairing heap.

Author
K. Lange klang.nosp@m.e@to.nosp@m.aruos.nosp@m..org

Provides a simple min-heap with insert, pop, peek, and visit.

A Kuroko implementation is provided as a backup alongside a faster C implementation in a shared object module.

Classes

_class PHeap_krk(object)

_let x = PHeap_krk(comp)

PHeap_krk.__init__(comp)

Create a new pairing heap governed by the given comparator function.

_PHeap_krk.__bool__()

_len(PHeap_krk)

PHeap_krk.__len__()

_PHeap_krk.insert(value)

Insert a new element into the heap.

_PHeap_krk.peek()

Retrieve the root (smallest) element of the heap, or None if it is empty.

_PHeap_krk.pop()

Remove and return the root (smallest) element of the heap. If the heap is empty, IndexError is raised.

_PHeap_krk.visit(func,after)

Call a function for each element of the heap.