Function: map-contains-key
map-contains-key is a byte-compiled function defined in map.el.gz.
Signature
(map-contains-key MAP KEY)
Documentation
Return non-nil if and only if MAP contains KEY.
TESTFN is deprecated. Its default depends on MAP.
The default implementation delegates to map-some.
Other relevant functions are documented in the map group.
Probably introduced at or before Emacs version 27.1.
Shortdoc
;; map
(map-contains-key (list 'bar 1 'foo 2 'baz 3) 'foo)
=> (foo 2 baz 3)
(map-contains-key (list '(bar . 1) '(foo . 2) '(baz . 3)) 'foo)
=> t
(map-contains-key [bar foo baz] 1)
=> t
(map-contains-key #s(hash-table data (bar 1 foo 2 baz 3)) 'foo)
=> t
Implementations
(map-contains-key (MAP hash-table) KEY &optional TESTFN) in `map.el'.
Implementation of `map-contains-key' for maps that are hash-tables. Returns non-nil if MAP contains KEY, ignoring TESTFN. In a map that is a hash-table, the keys in the table serve as the map keys and the associated values are the key values.
(map-contains-key (MAP array) KEY &optional TESTFN) in `map.el'.
Implementation of `map-contains-key' for maps that are arrays. In a map that is an array, the keys are the slot indices, and slot contents are the values. Returns non-nil if KEY is a valid index in MAP, ignoring TESTFN.
(map-contains-key (MAP list) KEY &optional TESTFN) in `map.el'.
Implementation of `map-contains-key' for maps that are plists or alists. If MAP is an alist, TESTFN defaults to `equal'. If MAP is a plist, TESTFN defaults to `eq'. In a map that is a plist, property names are the keys, and the corresponding property values are the values of those keys. In a map that is an alist, the `car' of each cons cell is the key and the `cdr' is the value.
(map-contains-key MAP KEY &optional TESTFN) in `map.el'.
Undocumented
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/map.el.gz
(cl-defgeneric map-contains-key (map key &optional testfn)
;; FIXME: The test function to use generally depends on the map object,
;; so specifying `testfn' here is problematic: e.g. for hash-tables
;; we shouldn't use `gethash' unless `testfn' is the same as the map's own
;; test function!
"Return non-nil if and only if MAP contains KEY.
TESTFN is deprecated. Its default depends on MAP.
The default implementation delegates to `map-some'."
(declare (advertised-calling-convention (map key) "27.1"))
(unless testfn (setq testfn #'equal))
(map-some (lambda (k _v) (funcall testfn key k)) map))