#ifdef STATISTICS #include "Behavioural/include/Stat_binary_tree.h" namespace morpheo { namespace behavioural { bool Stat_binary_tree::valid (void) { if (_data_type == NONE) return false; if ((_data_type == VARIABLE) or (_data_type == CONSTANT)) return ((_left == NULL) and (_right == NULL) ); if (_data_type == OPERATOR_UNARY) return ((_right == NULL) and (_left != NULL) and (_left->valid())); if (_data_type == OPERATOR_BINARY) return ((_left != NULL ) and (_left ->valid()) and (_right != NULL ) and (_right->valid())); return false; } void Stat_binary_tree::print (uint32_t depth) { std::string tab = std::string(depth,'\t'); std::string sep = " "; if (_data_type == NONE) { std::cout << tab << " NONE (error)" << std::endl; if (_left != NULL) _left ->print(depth+1); if (_right != NULL) _right->print(depth+1); } if ((_data_type == VARIABLE) or (_data_type == CONSTANT)) { std::cout << tab << "" << " " << ((_left == NULL)?"left == NULL ":"left != NULL (error)") << " " << ((_right == NULL)?"right == NULL ":"right != NULL (error)") << std::endl; if (_left != NULL) _left ->print(depth+1); if (_right != NULL) _right->print(depth+1); } if (_data_type == OPERATOR_UNARY) { std::cout << tab << "" << " " << ((_left == NULL)?"left == NULL (error)":"left != NULL ") << " " << ((_right == NULL)?"right == NULL ":"right != NULL (error)") << std::endl; if (_left != NULL) _left ->print(depth+1); if (_right != NULL) _right->print(depth+1); } if (_data_type == OPERATOR_BINARY) { std::cout << tab << "" << " " << ((_left == NULL)?"left == NULL (error)":"left != NULL ") << " " << ((_right == NULL)?"right == NULL (error)":"right != NULL ") << std::endl; if (_left != NULL) _left ->print(depth+1); if (_right != NULL) _right->print(depth+1); } } }; }; #endif