summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)))