RedBlackTree enumIter

Enumerates all iterators in key ascending order using an input function with the possibility to interrupt. Elements can be read and written using this function, as well as erased and inserted to the tree using the iterators given in the body.

Arguments

tree
is the RedBlackTree to enumerate.
body
is the callable to be called for each entry. It has the following stack notation:

( iterator -- condition )

Each RedBlackTreeIterator for each entry will be provided as input

iterator
to the callable. When the output
condition
is FALSE, enumeration interrupts.

Return values

None

Complexity

O(size)

Example

"sl/redBlackTree" useFile a: RedBlackTree; 0 "ZERO" a.insert 34 "element" a.insert -25 "element" a.insert 35 "element" a.insert 3483 135 a.insert 32 { a:0; b:1; } a.insert mod2: [drop FALSE] func; mod2: [2 mod 0 =] [drop TRUE] pfunc; a [it:; it.get.key mod2 [it a.eraseIter] when TRUE] enumIter a [print LF print TRUE] enum
Output:
{ key: -25; value: "element"; } { key: 35; value: "element"; } { key: 3483; value: 135; }