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


C++ VertexList::rend方法代码示例

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


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

示例1: DoTopologicalSort


//.........这里部分代码省略.........
        // Determine what Blocks caused the loop
        typedef std::map< Vertex, int > VertexStrongComponentIndexMap;
        VertexStrongComponentIndexMap vertexStrongComponentIndexMap;
        boost::associative_property_map< VertexStrongComponentIndexMap > apmVertexStrongComponentIndexMap( vertexStrongComponentIndexMap );
        strong_components( graph, apmVertexStrongComponentIndexMap );

        typedef std::vector< Vertex > VertexVector;
        typedef std::map< int, VertexVector > StrongComponentIndexVertexGroupMap;
        StrongComponentIndexVertexGroupMap strongComponentIndexVertexGroupMap;
        for( VertexStrongComponentIndexMap::iterator vsmItr = vertexStrongComponentIndexMap.begin(); vsmItr != vertexStrongComponentIndexMap.end(); ++vsmItr ) {
            strongComponentIndexVertexGroupMap[ vsmItr->second ].push_back( vsmItr->first );
        }

        std::string error( "Dataflow Graph '" + static_cast< std::string >( subsystem.Name() ) + "' has unhandled loops: " );
        for( StrongComponentIndexVertexGroupMap::iterator svmItr = strongComponentIndexVertexGroupMap.begin(); svmItr != strongComponentIndexVertexGroupMap.end(); ++svmItr ) {
            VertexVector vertexVector = svmItr->second;
            if ( vertexVector.size() <= 1 ) continue;
            error.append( "\n" );
            for( VertexVector::iterator vtvItr = vertexVector.begin(); vtvItr != vertexVector.end(); ++vtvItr ) {
                error.append( blockVector[ *vtvItr ].getPath("/") );
                error.append( ", " );
            }
            error.erase( error.size() - 2 );
        }

        throw udm_exception(error);
    }

    typedef std::set< Vertex > VertexSet;
    typedef std::map< int, VertexSet > PriorityVertexSetMap;

    PriorityVertexSetMap priorityVertexSetMap;
    for( BlockVector::iterator blvItr = blockVector.begin() ; blvItr != blockVector.end() ; ++blvItr ) {

        SLSF::Block block = *blvItr;
        int priority = block.Priority();
        if ( priority == 0 ) continue;

        Vertex vertex = blockVertexIndexMap[ block ];
        priorityVertexSetMap[ priority ].insert( vertex );
    }

    if ( priorityVertexSetMap.size() > 1 ) {
        PriorityVertexSetMap::iterator lstPvmItr = priorityVertexSetMap.end();
        --lstPvmItr;
        for( PriorityVertexSetMap::iterator pvmItr = priorityVertexSetMap.begin() ; pvmItr != lstPvmItr ; ) {
            PriorityVertexSetMap::iterator nxtPvmItr = pvmItr;
            ++nxtPvmItr;

            VertexSet &higherPriorityVertexSet = pvmItr->second;
            VertexSet &lowerPriorityVertexSet = nxtPvmItr->second;

            for( VertexSet::iterator hvsItr = higherPriorityVertexSet.begin() ; hvsItr != higherPriorityVertexSet.end() ; ++hvsItr ) {
                for( VertexSet::iterator lvsItr = lowerPriorityVertexSet.begin() ; lvsItr != lowerPriorityVertexSet.end() ; ++lvsItr ) {
                    boost::add_edge( *hvsItr, *lvsItr, graph );
                    LoopDetector loopDetector( graph );
                    if (  loopDetector.check( *hvsItr )  ) {
                        SLSF::Block higherPriorityBlock = vertexIndexBlockMap[ *hvsItr ];
                        SLSF::Block lowerPriorityBlock = vertexIndexBlockMap[ *lvsItr ];

                        std::cerr << "WARNING:  Cannot implement priority difference between block \"" << higherPriorityBlock.getPath( "/" ) << "\" (Priority = " << *hvsItr << ") and " << std::endl;
                        std::cerr << "          block \"" << lowerPriorityBlock.getPath( "/" ) << "\" (Priority = " << *lvsItr << "): contradicts topology of subsystem or other implemented block priority order." << std::endl;
                        boost::remove_edge( *hvsItr, *lvsItr, graph );
                    }
                }
            }
            pvmItr = nxtPvmItr;
        }
    }

    VertexList vertexList;
    boost::topological_sort(  graph, std::back_inserter( vertexList )  );


    /* PUT ALL "DataStoreMemory" BLOCKS AT END OF "C" SO THEY HAVE HIGHEST PRIORITY */
    VertexList::reverse_iterator vtlRit = vertexList.rbegin();
    while( vtlRit != vertexList.rend() ) {
        int index = *vtlRit;
        SLSF::Block block = vertexIndexBlockMap[ index ];

        (void)++vtlRit;
        if ( block != Udm::null && static_cast< std::string >( block.BlockType() ) == "DataStoreMemory"  ) {
            VertexList::reverse_iterator vtlRit2 = vtlRit;
            vertexList.splice( vertexList.end(), vertexList, vtlRit2.base() );
        }
    }

    int priority = 0;
    for( VertexList::reverse_iterator vtlRit = vertexList.rbegin() ; vtlRit != vertexList.rend() ; ++vtlRit ) {
        int index = *vtlRit;
        SLSF::Block block = vertexIndexBlockMap[ index ];
        if ( block == Udm::null ) { // unit delay as source is not registered - we will invoke it initially, and invoke it as destination in the priority order
            // const std::string& bt = blk.BlockType();
            // assert(bt.compare("UnitDelay") == 0);
            /* Unit Delay Block as destination */
            continue;
        }
        block.Priority() = priority++;
    }
}
开发者ID:pombredanne,项目名称:metamorphosys-desktop,代码行数:101,代码来源:utils.cpp


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