当前位置: 首页>>代码示例>>C++>>正文


C++ DagNode::incrementReferenceCount方法代码示例

本文整理汇总了C++中DagNode::incrementReferenceCount方法的典型用法代码示例。如果您正苦于以下问题:C++ DagNode::incrementReferenceCount方法的具体用法?C++ DagNode::incrementReferenceCount怎么用?C++ DagNode::incrementReferenceCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DagNode的用法示例。


在下文中一共展示了DagNode::incrementReferenceCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

/**
 * Overloaded assignment operator.
 * We need a deep copy of the operator.
 */
MetropolisHastingsMove& MetropolisHastingsMove::operator=(const RevBayesCore::MetropolisHastingsMove &m)
{

    if ( this != &m )
    {
        // free memory
        delete proposal;

        for (std::set<DagNode*>::iterator it = nodes.begin(); it != nodes.end(); ++it)
        {
            // get the pointer to the current node
            DagNode* theNode = *it;

            // add myself to the set of moves
            theNode->removeMove( this );

            // decrease the DAG node reference count because we also have a pointer to it
            if ( theNode->decrementReferenceCount() == 0 )
            {
                delete theNode;
            }

        }

        affectedNodes   = m.affectedNodes;
        nodes           = m.nodes;
        numAccepted     = m.numAccepted;
        proposal        = m.proposal->clone();


        for (std::set<DagNode*>::iterator it = nodes.begin(); it != nodes.end(); ++it)
        {
            // get the pointer to the current node
            DagNode* theNode = *it;

            // add myself to the set of moves
            theNode->addMove( this );

            // increase the DAG node reference count because we also have a pointer to it
            theNode->incrementReferenceCount();

        }
    }

    return *this;
}
开发者ID:wrightaprilm,项目名称:revbayes,代码行数:50,代码来源:MetropolisHastingsMove.cpp

示例2:

/**
 * Overloaded assignment operator.
 * We need a deep copy of the operator.
 */
AbstractMove& AbstractMove::operator=(const RevBayesCore::AbstractMove &m)
{
    
    if ( this != &m )
    {
        // delegate
        Move::operator=(m);
        
        for (size_t i = 0; i < nodes.size(); ++i)
        {
            // get the pointer to the current node
            DagNode* theNode = nodes[i];
            
            // add myself to the set of moves
            theNode->removeMove( this );
            
            // decrease the DAG node reference count because we also have a pointer to it
            if ( theNode->decrementReferenceCount() == 0 )
            {
                delete theNode;
            }
            
        }
        
        affectedNodes   = m.affectedNodes;
        nodes           = m.nodes;
        
        
        for (size_t i = 0; i < nodes.size(); ++i)
        {
            // get the pointer to the current node
            DagNode* theNode = nodes[i];
            
            // add myself to the set of moves
            theNode->addMove( this );
            
            // increase the DAG node reference count because we also have a pointer to it
            theNode->incrementReferenceCount();
            
        }
        
    }
    
    return *this;
}
开发者ID:hscarter,项目名称:revbayes,代码行数:49,代码来源:AbstractMove.cpp

示例3: nodes

/**
 * Constructor
 *
 * Here we simply allocate and initialize the move object.
 *
 * \param[in]    w   The weight how often the proposal will be used (per iteration).
 * \param[in]    t   If auto tuning should be used.
 */
AbstractMove::AbstractMove( const std::vector<DagNode*> &n, double w, bool t ) :
    nodes( n ),
    affectedNodes( ),
    weight( w ),
    autoTuning( t )
{
    
    for (std::vector<DagNode*>::iterator it = nodes.begin(); it != nodes.end(); ++it)
    {
        // get the pointer to the current node
        DagNode* theNode = *it;
        
        // add myself to the set of moves
        theNode->addMove( this );
        
        // increase the DAG node reference count because we also have a pointer to it
        theNode->incrementReferenceCount();
        
    }
    
    
    // remove all "core" nodes from affectedNodes so their probabilities are not double-counted
    for (size_t i = 0; i < affectedNodes.size(); ++i)
    {
        RbOrderedSet<DagNode*>::iterator it = affectedNodes.begin();
        std::advance(it, i);
        
        for (size_t j = 0; j < nodes.size(); ++j)
        {
            if ( nodes[j] == *it )
            {
                affectedNodes.erase(*it);
                --i;
                break;
            }
            
        }
        
    }
    
}
开发者ID:hscarter,项目名称:revbayes,代码行数:49,代码来源:AbstractMove.cpp

示例4: AbstractMove

/**
 * Copy constructor.
 * We need to create a deep copy of the proposal here.
 *
 * \param[in]   m   The object to copy.
 *
 */
MetropolisHastingsMove::MetropolisHastingsMove(const MetropolisHastingsMove &m) : AbstractMove(m),
    affectedNodes( m.affectedNodes ),
    nodes( m.nodes ),
    numAccepted( m.numAccepted ),
    proposal( m.proposal->clone() )
{

    for (std::set<DagNode*>::iterator it = nodes.begin(); it != nodes.end(); ++it)
    {
        // get the pointer to the current node
        DagNode* theNode = *it;

        // add myself to the set of moves
        theNode->addMove( this );

        // increase the DAG node reference count because we also have a pointer to it
        theNode->incrementReferenceCount();

    }

}
开发者ID:wrightaprilm,项目名称:revbayes,代码行数:28,代码来源:MetropolisHastingsMove.cpp

示例5: Move

AbstractMove::AbstractMove( const AbstractMove &m ) : Move( m ),
    nodes( m.nodes ),
    affectedNodes( m.affectedNodes ),
    weight( m.weight ),
    autoTuning( m.autoTuning  )
{
    
    
    for (size_t i = 0; i < nodes.size(); ++i)
    {
        // get the pointer to the current node
        DagNode* theNode = nodes[i];
        
        // add myself to the set of moves
        theNode->addMove( this );
        
        // increase the DAG node reference count because we also have a pointer to it
        theNode->incrementReferenceCount();
        
    }
    
}
开发者ID:hscarter,项目名称:revbayes,代码行数:22,代码来源:AbstractMove.cpp


注:本文中的DagNode::incrementReferenceCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。