use std::cell::RefCell;

pub struct Tree<T> {
    pub vec: Vec<RefCell<Node<T>>>,
}

impl<T> Tree<T> {
    pub fn new_node(&mut self, obj: T) -> usize {
        let index = self.vec.len();
        self.vec.push(RefCell::new(Node::new(obj)));
        index
    }
    pub fn set_parent_child(parent: usize, child: usize) {
        self.vec[child].parent = Some(parent);
        self.vec[parent].children.push(child);
    }
}

impl<T> Iterator for Tree<T> {
//    type Item =
}

pub struct Node<T> {
    pub parent: Option<usize>,
    pub children: Vec<usize>,
    pub data: T,
}

impl<T> Node<T> {
    pub fn new(obj: T) -> Self {
        Node {
            parent: None,
            children: Vec::new(),
            data: obj,
        }
    }
}

impl<T> Tree<T> {
    pub new() -> Self {
        vec: Vec::new(),
    }
    pub add_child(parent: usize
}

#[test]
fn test() {
    let mut tree = Tree::new();
