[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/heap ed90e4d 09/31: Adding missing 'buffer setting to c
From: |
Stefan Monnier |
Subject: |
[elpa] externals/heap ed90e4d 09/31: Adding missing 'buffer setting to customization menu for predictive-auto-add-to-dict. |
Date: |
Mon, 14 Dec 2020 12:13:34 -0500 (EST) |
branch: externals/heap
commit ed90e4d475e5e5e90e269db254877106ddf6e671
Author: Toby Cubitt <toby-predictive@dr-qubit.org>
Commit: tsc25 <toby-predictive@dr-qubit.org>
Adding missing 'buffer setting to customization menu for
predictive-auto-add-to-dict.
---
heap.el | 65 +++++++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 39 insertions(+), 26 deletions(-)
diff --git a/heap.el b/heap.el
index 52b9c8c..2d96f06 100644
--- a/heap.el
+++ b/heap.el
@@ -2,10 +2,10 @@
;;; heap.el --- heap (a.k.a. priority queue) data structure package
-;; Copyright (C) 2004-2006 Toby Cubitt
+;; Copyright (C) 2004-2006, 2008 Toby Cubitt
;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.2
+;; Version: 0.2.1
;; Keywords: heap, priority queue
;; URL: http://www.dr-qubit.org/emacs.php
@@ -30,40 +30,53 @@
;;; Commentary:
;;
-;; A heap is a form of efficient self-sorting tree (sometimes called a
-;; priority queue). 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.
+;; 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.
;;
-;; A heap consists of two cons cells, the first one holding the tag
-;; 'HEAP in the car cell and the second one having the heap in the car
-;; and the compare function in the cdr cell. The compare function must
-;; take two arguments of the type which is to be stored in the heap
-;; and must return non-nil or nil. To implement a max-heap, it should
-;; return non-nil if the first argument is "greater" than the
-;; second. To implement a min-heap, it should return non-nil if the
-;; first argument is "less than" the second.
+;; This package implements a ternary heap, 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 heap operations is the same as for a binary
+;; heap: `add', `delete-root' and `modify' 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 over-filling
+;; the heap is O(n) instead of O(log n).
+;;
+;; A heap consists of two cons cells, the first one holding the tag 'HEAP
+;; in the car cell and the second one having the heap in the car and the
+;; compare function in the cdr cell. The compare function must take two
+;; arguments of the type which is to be stored in the heap and must
+;; return non-nil or nil. To implement a max-heap, it should return
+;; non-nil if the first argument is "greater" than the second. To
+;; implement a min-heap, it should return non-nil if the first argument
+;; is "less than" the second.
;;
;; You create a heap using `heap-create', 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 convenience functions are
-;; also provided.
+;; `heap-modify'. A number of other 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.
;;
-;; Note that this package implements a ternary heap, since ternary
-;; heaps 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.
;;; Change log:
;;
+;; Version 0.2.1
+;; * modified Commentary
+;;
;; Version 0.2
;; * fixed efficiency issue: vectors are no longer copied all the time
-;; (thanks to Stefan Monnier for pointing out this issue)
+;; (thanks to Stefan Monnier for pointing this out)
;;
;; Version 0.1.5
;; * renamed `vswap' to `heap--vswap'
@@ -296,7 +309,7 @@ to 1.5"
(defun heap-delete-root (heap)
"Return the root of the heap and delete it from the heap."
(let (vect root (count (heap--count heap)))
-
+
;; deal with empty heaps and heaps with just one element
(if (= count 0) nil
(setq vect (heap--vect heap))
@@ -324,7 +337,7 @@ stored in the heap, and return non-nil if it should be
modified,
nil otherwise.
Note that only the match highest up the heap is modified."
-
+
(let ((vect (heap--vect heap))
(count (heap--count heap))
(i 0))
- [elpa] branch externals/heap created (now 32e75bb), Stefan Monnier, 2020/12/14
- [elpa] externals/heap 37bc0e9 05/31: Version 0.10 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/heap 03a876d 02/31: Version 0.2 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/heap ceb5dd1 21/31: Trivial whitespace tidying., Stefan Monnier, 2020/12/14
- [elpa] externals/heap 17429ee 07/31: Version 0.12 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/heap 55d47fd 11/31: Fixed ancient but overlooked bug in heap resizing in heap-add., Stefan Monnier, 2020/12/14
- [elpa] externals/heap 9bcd8d3 16/31: Added heap-build function for efficiently building a heap out of a vector., Stefan Monnier, 2020/12/14
- [elpa] externals/heap ed90e4d 09/31: Adding missing 'buffer setting to customization menu for predictive-auto-add-to-dict.,
Stefan Monnier <=
- [elpa] externals/heap f74c766 15/31: Converted heap data structures to defstructs., Stefan Monnier, 2020/12/14
- [elpa] externals/heap e354b4f 19/31: Revert default heap size to 10., Stefan Monnier, 2020/12/14
- [elpa] externals/heap e2c16be 06/31: Version 0.10.3 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/heap 75b42f4 04/31: Version 0.9.1 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/heap 2d51c84 01/31: Version 0.1 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/heap 227de61 03/31: Version 0.7 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/heap da9637e 25/31: Added heap-clear function., Stefan Monnier, 2020/12/14
- [elpa] externals/heap 4407826 22/31: More minor whitespace and commentary changes., Stefan Monnier, 2020/12/14
- [elpa] externals/heap 7f5ab59 10/31: Add heap-root function., Stefan Monnier, 2020/12/14
- [elpa] externals/heap 304c604 13/31: Fixed bug in heap-copy., Stefan Monnier, 2020/12/14