Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface BinaryTree<TreeType, Node> {
- Node left(TreeType t, Node node);
- Node right(TreeType t, Node node);
- }
- interface BinaryTreeWithRoot<TreeType, Node> : BinaryTree<TreeType, Node> {
- Node root(TreeType t);
- }
- interface BinaryTreeWithParentLink<TreeType, Node> : BinaryTree<TreeType, Node> {
- Node parent(TreeType t, Node node);
- }
- // Now an implementation of the Subtree.
- // The subtree object won't be tied to a specific BinaryTree.
- class Subtree<Tree, TreeType, Node> : BinaryTreeWithRoot<TreeType, Node>, Tree
- where Tree : BinaryTree<TreeType, Node> {
- // During initialization, initialize the root as a node from the tree.
- public Subtree(Node root);
- Node root;
- override BinaryTreeWithRoot<TreeType, Node>.root(TreeType t) {
- return this.root;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement