mardi 21 juillet 2015

Binary Tree using standard containers

I want to store a binary tree where each node is a T type. Due to the absence of standard tree container, I suggested this way:

    std::map<size_t,std::pair<T,T>> my_tree;
WHERE:
    size_t : the depth
    std::pair<T,T> :left and right branches

I do not feel that it's a professional way.. Any suggestion? P.S. I do not prefer 3rd-party library. thanks :)

Aucun commentaire:

Enregistrer un commentaire