summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2021-04-28 21:09:43 -0400
committerDavid Thompson <dthompson2@worcester.edu>2021-04-28 21:09:43 -0400
commit5455bb27b00108920a566bdfb4eea21b2d7e4569 (patch)
tree9be05fe23ff162dd2859f51f6d0a6eabae90698f
parentd4f19639bd4c7094a8e146f27427b8ebe033a499 (diff)
queue: Add queue-clear! procedure.
-rw-r--r--chickadee/queue.scm8
1 files changed, 7 insertions, 1 deletions
diff --git a/chickadee/queue.scm b/chickadee/queue.scm
index 51cec76..39f6318 100644
--- a/chickadee/queue.scm
+++ b/chickadee/queue.scm
@@ -25,7 +25,8 @@
queue-length
queue-empty?
enqueue!
- dequeue!))
+ dequeue!
+ queue-clear!))
(define-record-type <queue>
(%make-queue input output)
@@ -66,3 +67,8 @@
(array-list-push! output (array-list-pop! input))
(loop))))
(array-list-pop! output))))
+
+(define (queue-clear! q)
+ "Remove all items from Q."
+ (array-list-clear! (queue-input q))
+ (array-list-clear! (queue-output q)))