changeset 63727:fe0423976eb0

(ring-elements): Make it return a list of the elements of RING in order, and without bogus nil elements.
author Luc Teirlinck <teirllm@auburn.edu>
date Fri, 24 Jun 2005 01:20:14 +0000
parents 1d86d5c00a50
children 8473f6269712
files lisp/emacs-lisp/ring.el
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/ring.el	Thu Jun 23 21:49:52 2005 +0000
+++ b/lisp/emacs-lisp/ring.el	Fri Jun 24 01:20:14 2005 +0000
@@ -155,8 +155,13 @@
       (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: