deferred class TREE_OPERATOR[T] -- This class defines the interface for user-defined operations on binary -- trees. The idea is that the class TREE contains a special feature for -- applying operators to trees, and the user can define operators to do -- anything he wants. If t is a tree and op is an operator then the command -- t.apply(op) applies op to t. This means that t.apply first calls -- op.start, then it calls op.apply once for each node in the tree, passing -- the node as an argument, and then it calls op.finish. The order in which -- nodes are processed is determined by the attribute `traversal', which must -- be initialised at creation time to one of the three values `Preorder' -- (visit a node before its subtrees), `Inorder' (visit a node after its left -- subtree but before its right) and `Postorder' (visit a node after its -- subtrees). To use this facility, the user must create a new class that -- inherits from TREE_OPERATOR and supply an implementation for op.apply. By -- default, op.start and op.finish do nothing, but they can be redefined. feature {TREE} start is do end -- start finish is do end -- finish apply( n: NODE[T] ) is deferred end -- apply feature {ANY} Preorder, Inorder, Postorder : INTEGER is unique traversal : INTEGER invariant traversal = Preorder or traversal = Inorder or traversal = Postorder end -- class TREE_OPERATOR[T]