Previous: bst bnodes iterating breadth-first, Up: bst bnodes iterating [Index]
Iteration thunks are procedures accepting no arguments and returning an
item from a collection; when the iteration finishes: the return value is
the void object. Iteration thunks can be used with the facilities of
the library (vicare containers iteration-thunks)
(see iteration thunks). The following syntactic bindings are
exported by the library (vicare containers binary-search-trees)
.
Build and return an iteration thunk visiting the node of a tree with a
in–order forwards or backwards iteration. root must be #f
to represent an empty tree or an instance of <binary-node>
representing the root of a tree.
Here is an example with the fixnum trees defined in the introduction (see bst intro):
(import (vicare containers iteration-thunks)) (define root ;; 5-------10----12 ;; | | | ;; 1--3--4 7--9 11 ;; | | | ;; 2 6 8 (tree 5 1 3 2 4 10 7 12 6 9 8 11)) (iteration-thunk-fold (lambda (knil node) (cons (<fixnum-node>-sort-key node) knil)) '() (make-binary-tree-forwards-in-order-iteration-thunk root)) ⇒ (12 11 10 9 8 7 6 5 4 3 2 1)
Build and return an iteration thunk visiting the node of a tree with a
pre–order forwards or backwards iteration. root must be #f
to represent an empty tree or an instance of <binary-node>
representing the root of a tree.
Build and return an iteration thunk visiting the node of a tree with a
post–order forwards or backwards iteration. root must be
#f
to represent an empty tree or an instance of
<binary-node>
representing the root of a tree.
Build and return an iteration thunk visiting the node of a tree with a
level–order forwards or backwards iteration. root must be
#f
to represent an empty tree or an instance of
<binary-node>
representing the root of a tree.
Build and return an iteration thunk visiting the node of a tree with a
breadth–first forwards or backwards iteration. root must be
#f
to represent an empty tree or an instance of
<binary-node>
representing the root of a tree.
Previous: bst bnodes iterating breadth-first, Up: bst bnodes iterating [Index]