ilusm.dev

heap

Binary min-heap / max-heap with custom comparators.

Load with: use heap

Quick example

use heap

result = hpnew("value")
prn(result)

Functions

Functions

hpnew(cmp)

Performs the operation. Takes cmp.

hpmin()

Initialises.

hpmax()

Performs the operation.

hppsh(h, val)

Performs the operation. Takes h, val.

hppek(h)

Performs the operation. Takes h.

hppop(h)

Opens a connection or resource. Takes h.

hpsz(h)

Returns the size or count. Takes h.

hpmt(h)

Performs the operation. Takes h.

hpup(h, i)

Updates. Takes h, i.

hpdn(h, i)

Performs the operation. Takes h, i.

hpfr(xs, cmp)

Creates from another format. Takes xs, cmp.

hpsr(xs)

Performs the operation. Takes xs.

hpmg(a, b)

Performs the operation. Takes a, b.

hpls(h)

Lists items. Takes h.

Module aliases

These are the public-facing names you call with use heap:

  • heap.new(c)
  • heap.min()
  • heap.max()
  • heap.psh(h, v)
  • heap.pek(h)
  • heap.pop(h)
  • heap.sz(h)
  • heap.mt(h)
  • heap.from(x, c)
  • heap.sort(x)
  • heap.mrg(a, b)

Notes

  • Binary heap / priority queue.