Function: ring-p
ring-p is an autoloaded and byte-compiled function defined in
ring.el.gz.
Signature
(ring-p X)
Documentation
Return t if X is a ring; nil otherwise.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/ring.el.gz
;;; ring.el --- handle rings of items -*- lexical-binding: t; -*-
;; Copyright (C) 1992, 2001-2022 Free Software Foundation, Inc.
;; Maintainer: emacs-devel@gnu.org
;; Keywords: extensions
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This code defines a ring data structure. A ring is a
;; (hd-index length . vector)
;; list. You can insert to, remove from, and rotate a ring. When the ring
;; fills up, insertions cause the oldest elts to be quietly dropped.
;;
;; In ring-ref, 0 is the index of the newest element. Higher indexes
;; correspond to older elements; when the index equals the ring length,
;; it wraps to the newest element again.
;;
;; hd-index = vector index of the oldest ring item.
;; Newer items follow this item; at the end of the vector,
;; they wrap around to the start of the vector.
;; length = number of items currently in the ring.
;; This never exceeds the length of the vector itself.
;;
;; These functions are used by the input history mechanism, but they can
;; be used for other purposes as well.
;;; Code:
;;; User Functions:
;;;###autoload
(defun ring-p (x)
"Return t if X is a ring; nil otherwise."
(and (consp x) (integerp (car x))
(consp (cdr x)) (integerp (cadr x))
(vectorp (cddr x))))