use {crate::Child, std::fmt};
pub type NodeId = usize;
#[derive(Debug, Clone, PartialEq)]
pub struct Node<Op>
where
Op: fmt::Debug + Clone + PartialEq,
{
pub operator: Option<Op>,
pub parent: Option<NodeId>,
pub left: Child,
pub right: Child,
pub unary: bool, }
impl<Op> Node<Op>
where
Op: fmt::Debug + Clone + PartialEq,
{
pub fn is_full(&self) -> bool {
if self.unary {
self.left.is_some()
} else {
self.right.is_some()
}
}
pub fn empty() -> Self {
Self {
operator: None,
parent: None,
left: Child::None,
right: Child::None,
unary: false,
}
}
}