Function: avl-tree-stack
avl-tree-stack is a byte-compiled function defined in avl-tree.el.gz.
Signature
(avl-tree-stack TREE &optional REVERSE)
Documentation
Return an object that behaves like a sorted stack of all elements of TREE.
If REVERSE is non-nil, the stack is sorted in reverse order.
(See also avl-tree-stack-pop).
Note that any modification to TREE *immediately* invalidates all
avl-tree-stacks created before the modification (in particular,
calling avl-tree-stack-pop will give unpredictable results).
Operations on these objects are significantly more efficient than
constructing a real stack with avl-tree-flatten and using
standard stack functions. As such, they can be useful in
implementing efficient algorithms of AVL trees. However, in cases
where mapping functions avl-tree-mapc, avl-tree-mapcar or
avl-tree-mapf would be sufficient, it is better to use one of
those instead.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/avl-tree.el.gz
(defun avl-tree-stack (tree &optional reverse)
"Return an object that behaves like a sorted stack of all elements of TREE.
If REVERSE is non-nil, the stack is sorted in reverse order.
\(See also `avl-tree-stack-pop').
Note that any modification to TREE *immediately* invalidates all
avl-tree-stacks created before the modification (in particular,
calling `avl-tree-stack-pop' will give unpredictable results).
Operations on these objects are significantly more efficient than
constructing a real stack with `avl-tree-flatten' and using
standard stack functions. As such, they can be useful in
implementing efficient algorithms of AVL trees. However, in cases
where mapping functions `avl-tree-mapc', `avl-tree-mapcar' or
`avl-tree-mapf' would be sufficient, it is better to use one of
those instead."
(let ((stack (avl-tree--stack-create tree reverse)))
(avl-tree--stack-repopulate stack)
stack))