#ifndef BINARYTREENODE_H #define BINARYTREENODE_H // // ============================================================ // // BinaryTree // // ============================================================ // // // Copyright (C) 1996 // // Professor Kenneth I. Joy // Computer Science Department // University of California // Davis, CA 95616 // // Permission is granted to use at your own risk and // distribute this software in source and binary forms // provided the above copyright notice and this paragraph // are preserved on all copies. This software is provided // "as is" with no express or implied warranty. // // // ============================================================ // class BinaryTree { private : // The values in the nodes double _value ; // The Pointers down the tree BinaryTree *_left_child, *_right_child ; // Private Copy Function friend BinaryTree * _Copy ( BinaryTree * ) ; public : // Constructors BinaryTree () ; BinaryTree ( const double, BinaryTree *, BinaryTree * ) ; // Copy Constructor BinaryTree ( const BinaryTree& ) ; // Destructor virtual ~BinaryTree () ; // Assignment BinaryTree& operator= ( const BinaryTree& ) ; // Output -- for both referenced lists and pointers friend ostream& operator<< ( ostream&, const BinaryTree& ) ; friend ostream& operator<< ( ostream&, const BinaryTree * ) ; // Comparison friend int operator== ( const BinaryTree&, const BinaryTree& ) ; friend int operator!= ( const BinaryTree&, const BinaryTree& ) ; // Add a Value to the tree so that inorder prints // out an ordered list. void add ( const double ) ; // Traversals void inorder() const ; void preorder() const ; void postorder() const ; // Access Functions double value() const { return _value ; } ; BinaryTree * left_child() const { return _left_child ; } ; BinaryTree * right_child() const { return _right_child ; } ; } ; #endif