;;; Code:
(eval-when-compile (require 'cl-lib))
-
+(require 'generator)
;; ================================================================
(null (avl-tree--stack-store avl-tree-stack)))
+(iter-defun avl-tree-iter (tree &optional reverse)
+ "Return an AVL tree iterator object.
+
+Calling `iter-next' on this object will retrieve the next element
+from TREE. If REVERSE is non-nil, elements are returned in
+reverse order.
+
+Note that any modification to TREE *immediately* invalidates all
+iterators created from TREE before the modification (in
+particular, calling `iter-next' will give unpredictable results)."
+ (let ((stack (avl-tree-stack tree reverse)))
+ (while (not (avl-tree-stack-empty-p stack))
+ (iter-yield (avl-tree-stack-pop stack)))))
+
+
(provide 'avl-tree)
;;; avl-tree.el ends here