3 (defun extreme-node-with-path (root direction &optional path)
4 (do ((node root (funcall direction node))
6 ((null node) (values parent path))
9 (defun make-iterator (tree &key
11 (current nil currentp)
13 (declare (type binary-tree tree))
14 (let ((modcount (modcount tree)))
15 (multiple-value-bind (extremum examine)
17 (values #'left #'right)
18 (values #'right #'left))
19 (multiple-value-bind (current stack)
20 (if (and currentp stackp)
21 (values current stack)
22 (extreme-node-with-path (root tree) extremum))
25 ((/= modcount (modcount tree))
26 (error "~A modified during iteration" tree))
32 (node (funcall examine top)))
35 (setf current (first stack)))
37 (setf (values current stack)
38 (extreme-node-with-path node extremum stack))))
39 (values next t)))))))))