[GIT] ppl/ppl(pip): Added a pointer to parent node in PIP_Tree_Node.
Module: ppl/ppl Branch: pip Commit: 8cba1ff2af0392b8f741c2a6dd4da99edcd56978 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=8cba1ff2af039... Author: François Galea <francois.galea@uvsq.fr> Date: Thu Nov 19 11:59:53 2009 +0100 Added a pointer to parent node in PIP_Tree_Node. --- src/PIP_Tree.cc | 18 ++++++++++++++---- src/PIP_Tree.defs.hh | 9 +++++++++ src/PIP_Tree.inlines.hh | 10 ++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc index b4996cf..64a65b9 100644 --- a/src/PIP_Tree.cc +++ b/src/PIP_Tree.cc @@ -148,12 +148,14 @@ operator<<(std::ostream& os, const PIP_Tree_Node::Artificial_Parameter& x) { } // namespace IO_Operators PIP_Tree_Node::PIP_Tree_Node() - : constraints_(), + : parent_(0), + constraints_(), artificial_parameters() { } PIP_Tree_Node::PIP_Tree_Node(const PIP_Tree_Node &x) - : constraints_(x.constraints_), + : parent_(0), + constraints_(x.constraints_), artificial_parameters(x.artificial_parameters) { } @@ -256,16 +258,24 @@ PIP_Decision_Node::PIP_Decision_Node(PIP_Tree_Node* fcp, : PIP_Tree_Node(), true_child(tcp), false_child(fcp) { + if (fcp != 0) + fcp->set_parent(this); + if (tcp != 0) + tcp->set_parent(this); } PIP_Decision_Node ::PIP_Decision_Node(const PIP_Decision_Node& x) : PIP_Tree_Node(x), true_child(0), false_child(0) { - if (x.true_child != 0) + if (x.true_child != 0) { true_child = x.true_child->clone(); - if (x.false_child != 0) + true_child->set_parent(this); + } + if (x.false_child != 0) { false_child = x.false_child->clone(); + false_child->set_parent(this); + } } const PIP_Solution_Node* diff --git a/src/PIP_Tree.defs.hh b/src/PIP_Tree.defs.hh index ae5a461..1e2e01a 100644 --- a/src/PIP_Tree.defs.hh +++ b/src/PIP_Tree.defs.hh @@ -150,12 +150,21 @@ protected: friend class PIP_Decision_Node; friend class PIP_Solution_Node; + //! A pointer to \p *this 's parent, or 0 if \p *this is the root node. + const PIP_Decision_Node* parent_; + //! The local system of parameter constraints. Constraint_System constraints_; //! The local sequence of expressions for local artificial parameters. Artificial_Parameter_Sequence artificial_parameters; + //! Set this node's parent to \p *p. + void set_parent(const PIP_Decision_Node* p); + + //! Returns a pointer to this node's parent. + const PIP_Decision_Node* parent() const; + /*! \brief Populates the parametric simplex tableau using external data, if necessary diff --git a/src/PIP_Tree.inlines.hh b/src/PIP_Tree.inlines.hh index 8901588..0e0b8f8 100644 --- a/src/PIP_Tree.inlines.hh +++ b/src/PIP_Tree.inlines.hh @@ -67,6 +67,16 @@ inline PIP_Tree_Node::~PIP_Tree_Node() { } +inline void +PIP_Tree_Node::set_parent(const PIP_Decision_Node* p) { + parent_ = p; +} + +inline const PIP_Decision_Node* +PIP_Tree_Node::parent() const { + return parent_; +} + inline const Constraint_System& PIP_Tree_Node::constraints() const { return constraints_;
participants (1)
-
François Galea