f3327aa93670

Add `:initial-contents` for `make-queue`
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 08 Dec 2019 12:29:06 -0500
parents 2309743a485d
children 164b3e41c13b
branches/tags (none)
files src/queues.lisp

Changes

--- a/src/queues.lisp	Fri Dec 06 21:04:10 2019 -0500
+++ b/src/queues.lisp	Sun Dec 08 12:29:06 2019 -0500
@@ -10,7 +10,7 @@
 
 
 (declaim
-  (ftype (function ()
+  (ftype (function (&key (:initial-contents list))
                    (values queue &optional))
          make-queue)
   (ftype (function (queue)
@@ -27,9 +27,12 @@
          queue-append))
 
 
-(defun-inlineable make-queue ()
+(defun-inlineable make-queue (&key initial-contents)
   "Allocate and return a fresh queue."
-  (make-queue%))
+  (let ((queue (make-queue%)))
+    (when initial-contents
+      (queue-append queue initial-contents))
+    queue))
 
 (defun-inlineable queue-empty-p (queue)
   "Return whether `queue` is empty."