]> git.eshelyaron.com Git - emacs.git/commitdiff
(ring-elements): Make it return a list of the elements of RING in
authorLuc Teirlinck <teirllm@auburn.edu>
Fri, 24 Jun 2005 01:20:14 +0000 (01:20 +0000)
committerLuc Teirlinck <teirllm@auburn.edu>
Fri, 24 Jun 2005 01:20:14 +0000 (01:20 +0000)
order, and without bogus nil elements.

lisp/emacs-lisp/ring.el

index fce07953ba92c5f93bd9c5d28c9141c029048301..6e0f9cd70b4bf2832895692c4263c7de44ce7c93 100644 (file)
@@ -155,8 +155,13 @@ will be performed."
       (aref vec (ring-index index hd ln (length vec))))))
 
 (defun ring-elements (ring)
-  "Return a list of the elements of RING."
-  (mapcar #'identity (cddr ring)))
+  "Return a list of the elements of RING, in order, newest first."
+  (let ((start (car ring))
+       (size (ring-size ring))
+       (vect (cddr ring))
+       lst)
+    (dotimes (var (cadr ring) lst)
+      (push (aref vect (mod (+ start var) size)) lst))))
 
 ;;; provide ourself: