diff options
| author | John Paul Wallington | 2003-07-11 21:53:43 +0000 |
|---|---|---|
| committer | John Paul Wallington | 2003-07-11 21:53:43 +0000 |
| commit | 2356fa8a91e305ab8a2286dc7545c2f69effac92 (patch) | |
| tree | d3c448613a399dd65dac7da3540bf529e23596ad | |
| parent | 2765b45784a3675fe2ce72bf13efa69a7f186cb4 (diff) | |
| download | emacs-2356fa8a91e305ab8a2286dc7545c2f69effac92.tar.gz emacs-2356fa8a91e305ab8a2286dc7545c2f69effac92.zip | |
2003-07-11 John Paul Wallington <jpw@gnu.org>
* emacs-lisp/ring.el (ring-empty-p): Use `zerop'.
(ring-p, ring-plus1, ring-minus1, ring-length, ring-index)
(ring-empty-p, ring-size, ring-copy, ring-ref): Doc fixes.
2003-07-11 NAKAJIMA Mikio <minakaji@namazu.org> (tiny change)
* emacs-lisp/ring.el (ring-elements): Doc fix.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/emacs-lisp/ring.el | 24 |
2 files changed, 22 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9a9d112ef68..7d80481f6a7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2003-07-11 John Paul Wallington <jpw@gnu.org> | ||
| 2 | |||
| 3 | * emacs-lisp/ring.el (ring-empty-p): Use `zerop'. | ||
| 4 | (ring-p, ring-plus1, ring-minus1, ring-length, ring-index) | ||
| 5 | (ring-empty-p, ring-size, ring-copy, ring-ref): Doc fixes. | ||
| 6 | |||
| 7 | 2003-07-11 NAKAJIMA Mikio <minakaji@namazu.org> (tiny change) | ||
| 8 | |||
| 9 | * emacs-lisp/ring.el (ring-elements): Doc fix. | ||
| 10 | |||
| 1 | 2003-07-11 Glenn Morris <gmorris@ast.cam.ac.uk> | 11 | 2003-07-11 Glenn Morris <gmorris@ast.cam.ac.uk> |
| 2 | 12 | ||
| 3 | * calendar/timeclock.el (timeclock-relative) | 13 | * calendar/timeclock.el (timeclock-relative) |
diff --git a/lisp/emacs-lisp/ring.el b/lisp/emacs-lisp/ring.el index e4cede28bd2..6891619c20e 100644 --- a/lisp/emacs-lisp/ring.el +++ b/lisp/emacs-lisp/ring.el | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | ;;; Commentary: | 25 | ;;; Commentary: |
| 26 | 26 | ||
| 27 | ;; This code defines a ring data structure. A ring is a | 27 | ;; This code defines a ring data structure. A ring is a |
| 28 | ;; (hd-index length . vector) | 28 | ;; (hd-index length . vector) |
| 29 | ;; list. You can insert to, remove from, and rotate a ring. When the ring | 29 | ;; list. You can insert to, remove from, and rotate a ring. When the ring |
| 30 | ;; fills up, insertions cause the oldest elts to be quietly dropped. | 30 | ;; fills up, insertions cause the oldest elts to be quietly dropped. |
| @@ -48,7 +48,7 @@ | |||
| 48 | 48 | ||
| 49 | ;;;###autoload | 49 | ;;;###autoload |
| 50 | (defun ring-p (x) | 50 | (defun ring-p (x) |
| 51 | "Returns t if X is a ring; nil otherwise." | 51 | "Return t if X is a ring; nil otherwise." |
| 52 | (and (consp x) (integerp (car x)) | 52 | (and (consp x) (integerp (car x)) |
| 53 | (consp (cdr x)) (integerp (car (cdr x))) | 53 | (consp (cdr x)) (integerp (car (cdr x))) |
| 54 | (vectorp (cdr (cdr x))))) | 54 | (vectorp (cdr (cdr x))))) |
| @@ -71,20 +71,20 @@ | |||
| 71 | (setcar (cdr ring) ln))) | 71 | (setcar (cdr ring) ln))) |
| 72 | 72 | ||
| 73 | (defun ring-plus1 (index veclen) | 73 | (defun ring-plus1 (index veclen) |
| 74 | "Returns INDEX+1, with wraparound." | 74 | "Return INDEX+1, with wraparound." |
| 75 | (let ((new-index (+ index 1))) | 75 | (let ((new-index (+ index 1))) |
| 76 | (if (= new-index veclen) 0 new-index))) | 76 | (if (= new-index veclen) 0 new-index))) |
| 77 | 77 | ||
| 78 | (defun ring-minus1 (index veclen) | 78 | (defun ring-minus1 (index veclen) |
| 79 | "Returns INDEX-1, with wraparound." | 79 | "Return INDEX-1, with wraparound." |
| 80 | (- (if (= 0 index) veclen index) 1)) | 80 | (- (if (= 0 index) veclen index) 1)) |
| 81 | 81 | ||
| 82 | (defun ring-length (ring) | 82 | (defun ring-length (ring) |
| 83 | "Returns the number of elements in the RING." | 83 | "Return the number of elements in the RING." |
| 84 | (car (cdr ring))) | 84 | (car (cdr ring))) |
| 85 | 85 | ||
| 86 | (defun ring-index (index head ringlen veclen) | 86 | (defun ring-index (index head ringlen veclen) |
| 87 | "Converts nominal ring index INDEX to an internal index. | 87 | "Convert nominal ring index INDEX to an internal index. |
| 88 | The internal index refers to the items ordered from newest to oldest. | 88 | The internal index refers to the items ordered from newest to oldest. |
| 89 | HEAD is the index of the oldest element in the ring. | 89 | HEAD is the index of the oldest element in the ring. |
| 90 | RINGLEN is the number of elements currently in the ring. | 90 | RINGLEN is the number of elements currently in the ring. |
| @@ -93,15 +93,15 @@ VECLEN is the size of the vector in the ring." | |||
| 93 | (mod (1- (+ head (- ringlen index))) veclen)) | 93 | (mod (1- (+ head (- ringlen index))) veclen)) |
| 94 | 94 | ||
| 95 | (defun ring-empty-p (ring) | 95 | (defun ring-empty-p (ring) |
| 96 | "Returns t if RING is empty; nil otherwise." | 96 | "Return t if RING is empty; nil otherwise." |
| 97 | (= 0 (car (cdr ring)))) | 97 | (zerop (car (cdr ring)))) |
| 98 | 98 | ||
| 99 | (defun ring-size (ring) | 99 | (defun ring-size (ring) |
| 100 | "Returns the size of RING, the maximum number of elements it can contain." | 100 | "Return the size of RING, the maximum number of elements it can contain." |
| 101 | (length (cdr (cdr ring)))) | 101 | (length (cdr (cdr ring)))) |
| 102 | 102 | ||
| 103 | (defun ring-copy (ring) | 103 | (defun ring-copy (ring) |
| 104 | "Returns a copy of RING." | 104 | "Return a copy of RING." |
| 105 | (let* ((vec (cdr (cdr ring))) | 105 | (let* ((vec (cdr (cdr ring))) |
| 106 | (hd (car ring)) | 106 | (hd (car ring)) |
| 107 | (ln (car (cdr ring)))) | 107 | (ln (car (cdr ring)))) |
| @@ -144,7 +144,7 @@ numeric, remove the element indexed." | |||
| 144 | oldelt))) | 144 | oldelt))) |
| 145 | 145 | ||
| 146 | (defun ring-ref (ring index) | 146 | (defun ring-ref (ring index) |
| 147 | "Returns RING's INDEX element. | 147 | "Return RING's INDEX element. |
| 148 | INDEX = 0 is the most recently inserted; higher indices | 148 | INDEX = 0 is the most recently inserted; higher indices |
| 149 | correspond to older elements. | 149 | correspond to older elements. |
| 150 | INDEX need not be <= the ring length; the appropriate modulo operation | 150 | INDEX need not be <= the ring length; the appropriate modulo operation |
| @@ -155,7 +155,7 @@ will be performed." | |||
| 155 | (aref vec (ring-index index hd ln (length vec)))))) | 155 | (aref vec (ring-index index hd ln (length vec)))))) |
| 156 | 156 | ||
| 157 | (defun ring-elements (ring) | 157 | (defun ring-elements (ring) |
| 158 | "Return a list of the lements of RING." | 158 | "Return a list of the elements of RING." |
| 159 | (mapcar #'identity (cddr ring))) | 159 | (mapcar #'identity (cddr ring))) |
| 160 | 160 | ||
| 161 | ;;; provide ourself: | 161 | ;;; provide ourself: |