Next: binary heaps misc, Previous: binary heaps sorting, Up: binary heaps [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-heaps).
Build and return a new iteration thunk popping the objects from stack.
(import (vicare)
(vicare containers binary-heaps)
(vicare containers iteration-thunks))
(define (xcons a b)
(cons b a))
(iteration-thunk-fold
xcons
'()
(make-binary-heap-iteration-thunk (make-binary-heap <)))
⇒ ()
(let ((H (make-binary-heap <)))
(binary-heap-fill! H '(3 5 7 0 6 5 34 3 6 9 67 5 4 4 3 1 2 3))
(iteration-thunk-fold
xcons
'()
(make-binary-heap-iteration-thunk H)))
⇒ (67 34 9 7 6 6 5 5 5 4 4 3 3 3 3 2 1 0)