heap

Description
Heap (a.k.a. priority queue) data structure
Latest
heap-0.5.0.20201214.121301.tar (.sig), 2024-Mar-31, 20.0 KiB
Maintainer
Toby Cubitt <toby-predictive@dr-qubit.org>
Atom feed
heap.xml
Website
http://www.dr-qubit.org/emacs.php
Browse ELPA's repository
CGit or Gitweb
Badge

To install this package from Emacs, use package-install or list-packages.

Full description

A heap is a form of efficient self-sorting tree. In particular, the root
node is guaranteed to be the highest-ranked entry in the tree. (The
comparison function used for ranking the data can, of course, be freely
defined). Therefore repeatedly removing the root node will return the data
in order of increasing rank. They are often used as priority queues, for
scheduling tasks in order of importance.

This package implements ternary heaps, since they are about 12% more
efficient than binary heaps for heaps containing more than about 10
elements, and for very small heaps the difference is negligible. The
asymptotic complexity of ternary heap operations is the same as for a
binary heap: 'add', 'delete-root' and 'modify' operations are all O(log n)
on a heap containing n elements.

Note that this package implements a heap as an implicit data structure on a
vector. Therefore, the maximum size of the heap has to be specified in
advance. Although the heap will grow dynamically if it becomes full, this
requires copying the entire heap, so insertion has worst-case complexity
O(n) instead of O(log n), though the amortized complexity is still
O(log n). (For applications where the maximum size of the heap is not known
in advance, an implementation based on binary trees might be more suitable,
but is not currently implemented in this package.)

You create a heap using `make-heap', add elements to it using `heap-add',
delete and return the root of the heap using `heap-delete-root', and modify
an element of the heap using `heap-modify'. A number of other heap
convenience functions are also provided, all with the prefix
`heap-'. Functions with prefix `heap--' are for internal use only, and
should never be used outside this package.

Old versions

heap-0.5.0.20201214.171301.tar.lz2020-Dec-144.14 KiB