Function: avl-tree-member
avl-tree-member is a byte-compiled function defined in avl-tree.el.gz.
Signature
(avl-tree-member TREE DATA &optional NILFLAG)
Documentation
Return the element in the AVL TREE which matches DATA.
Matching uses the comparison function previously specified in
avl-tree-create when TREE was created.
If there is no such element in the tree, nil is returned.
Optional argument NILFLAG specifies a value to return instead of nil
in this case. This allows non-existent elements to be distinguished
from a null element. (See also avl-tree-member-p, which does this
for you.)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/avl-tree.el.gz
(defun avl-tree-member (tree data &optional nilflag)
"Return the element in the AVL TREE which matches DATA.
Matching uses the comparison function previously specified in
`avl-tree-create' when TREE was created.
If there is no such element in the tree, nil is returned.
Optional argument NILFLAG specifies a value to return instead of nil
in this case. This allows non-existent elements to be distinguished
from a null element. (See also `avl-tree-member-p', which does this
for you.)"
(let ((node (avl-tree--root tree))
(compare-function (avl-tree--cmpfun tree)))
(catch 'found
(while node
(cond
((funcall compare-function data (avl-tree--node-data node))
(setq node (avl-tree--node-left node)))
((funcall compare-function (avl-tree--node-data node) data)
(setq node (avl-tree--node-right node)))
(t (throw 'found (avl-tree--node-data node)))))
nilflag)))