本文整理汇总了C++中Enode::setExpReason方法的典型用法代码示例。如果您正苦于以下问题:C++ Enode::setExpReason方法的具体用法?C++ Enode::setExpReason怎么用?C++ Enode::setExpReason使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enode
的用法示例。
在下文中一共展示了Enode::setExpReason方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expRemoveExplanation
//
// Undoes the effect of expStoreExplanation
//
void Egraph::expRemoveExplanation( )
{
assert( exp_undo_stack.size( ) >= 2 );
Enode * x = exp_undo_stack.back( );
exp_undo_stack.pop_back( );
Enode * y = exp_undo_stack.back( );
exp_undo_stack.pop_back( );
assert( x );
assert( y );
assert( !x->isEnil( ) );
assert( !y->isEnil( ) );
// We observe that we don't need to undo the rerooting
// of the explanation trees, because it doesn't affect
// correctness. We just have to reroot y on itself
assert( x->getExpParent( ) == y || y->getExpParent( ) == x );
if ( x->getExpParent( ) == y )
{
x->setExpParent( NULL );
x->setExpReason( NULL );
}
else
{
y->setExpParent( NULL );
y->setExpReason( NULL );
}
}
示例2: expReRootOn
//
// Subroutine of explainStoreExplanation
// Re-root the tree containing x, in such a way that
// the new root is x itself
//
void Egraph::expReRootOn ( Enode * x )
{
Enode * p = x;
Enode * parent = p->getExpParent( );
Enode * reason = p->getExpReason( );
x->setExpParent( NULL );
x->setExpReason( NULL );
while( parent != NULL )
{
// Save grandparent
Enode * grandparent = parent->getExpParent( );
// Save reason
Enode * saved_reason = reason;
reason = parent->getExpReason( );
// Reverse edge & reason
parent->setExpParent( p );
parent->setExpReason( saved_reason );
#ifdef PEDANTIC_DEBUG
assert( checkExpTree( parent ) );
#endif
// Move the two pointers
p = parent;
parent = grandparent;
}
}