clonable tree Nodes

6 views
Skip to first unread message

Laurent Guéguen

unread,
Nov 18, 2014, 9:25:08 AM11/18/14
to biopp-de...@googlegroups.com
Hi,

I want to exploit the clonability of some objects in a Tree.
Is it fine with any of you if I change TreeTemplateTools.h like this?

template<class N>
  static N* cloneSubtree(const Node& node)
  {
    // First we copy this node using default copy constuctor:
    N* clone;

    // previous version :  clone = new N(node);

    if (dynamic_cast<const Clonable*>(&node)==0)
      clone = new N(node);
    else
      clone = dynamic_cast<const N*>(&node)->clone();
   

    // We remove the link toward the father:
    // clone->removeFather();

    // Now we perform a hard copy:
    for (int i = 0; i < static_cast<int>(node.getNumberOfSons()); i++)
    {
      clone->addSon(cloneSubtree<N>(*node[i]));
    }
    return clone;
  }



Or is there a problem I missed?

Cheers,
Laurent

Julien Yann Dutheil

unread,
Nov 18, 2014, 9:32:42 AM11/18/14
to biopp-de...@googlegroups.com
Definitely fine and needed. I cannot see any issue with that.

J.
Reply all
Reply to author
Forward
0 new messages