From 8466d8cfa486fb30d1755c4261b781135083787b Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 20 Feb 2017 00:05:29 -0800 Subject: Import Upstream version 3a1 --- priorque.scm | 73 ++++++++++++++++++++++++++++-------------------------------- 1 file changed, 34 insertions(+), 39 deletions(-) (limited to 'priorque.scm') diff --git a/priorque.scm b/priorque.scm index 0ad3007..9f1591f 100644 --- a/priorque.scm +++ b/priorque.scm @@ -8,7 +8,7 @@ ;1. Any copy made of this software must include this copyright notice ;in full. ; -;2. I have made no warrantee or representation that the operation of +;2. I have made no warranty or representation that the operation of ;this software will be error-free, and I am under no obligation to ;provide any services, by way of maintenance, update, or otherwise. ; @@ -17,21 +17,20 @@ ;promotional, or sales literature without prior written consent in ;each case. -;;; Algorithm from: -;;; Introduction to Algorithms by T. Cormen, C. Leiserson, R. Rivest. -;;; 1989 MIT Press. +;;@code{(require 'priority-queue)} +;;@ftindex priority-queue +;; +;;@noindent +;;This algorithm for priority queues is due to +;;@cite{Introduction to Algorithms} +;;by T. Cormen, C. Leiserson, R. Rivest. +;;1989 MIT Press. (require 'record) ;; Record type. (define heap:rtd (make-record-type "heap" '(array size heap?)) - (heap-insert! heap #\A) - (heap-insert! heap #\Z) - (heap-insert! heap #\G) - (heap-insert! heap #\B) - (heap-insert! heap #\G) - (heap-insert! heap #\Q) - (heap-insert! heap #\S) - (heap-insert! heap #\R) - (do ((i 7 (+ -1 i))) - ((negative? i)) - (write (heap-extract-max! heap)) (newline)))) +;; Internal protect. +(define heap:length heap-length) -- cgit v1.2.3