redef fun show_dot do
assert not_empty: root != null
- var f = new OProcess("dot", "-Txlib")
+ var f = new ProcessWriter("dot", "-Txlib")
f.write "digraph \{\n"
dot_down(root.as(not null), f)
f.write "\}\n"
end
# Translate the tree in dot format starting from `node`.
- protected fun dot_down(node: N, f: OProcess) do
+ protected fun dot_down(node: N, f: ProcessWriter) do
if node.left != null then dot_down(node.left.as(not null), f)
f.write node.to_dot
if node.right != null then dot_down(node.right.as(not null), f)
class BinTreeNode[K: Comparable, E]
super TreeNode[K, E]
- private var prev: nullable BinTreeNode[K, E]
- private var next: nullable BinTreeNode[K, E]
+ private var prev: nullable BinTreeNode[K, E] = null
+ private var next: nullable BinTreeNode[K, E] = null
redef type N: BinTreeNode[K, E]
- init(key: K, item: E) do
- super(key, item)
- end
-
private var left_node: nullable N = null
# `left` tree node child (null if node has no left child)
private class BinTreeMapIterator[K: Comparable, E]
super MapIterator[K, E]
- var current: nullable BinTreeNode[K, E]
+ var tree: BinTreeMap[K, E]
+ var current: nullable BinTreeNode[K, E] = null
- init(tree: BinTreeMap[K, E]) do
- current = tree.first_node
- end
+ init do current = tree.first_node
redef fun is_ok do return not current == null
redef fun next do current = current.next