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


C++ Switch::isRouter方法代码示例

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


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

示例1: Request

Request * Preprocessor::fakeNetElements(Request * r) {
    Request * fakeRequest = new Request(*r);
    Elements netElements = Operation::filter(r->getElements(), Criteria::isSwitch);
    for ( Elements::iterator i = netElements.begin(); i != netElements.end(); i++ ) {
        Switch * netElement = (*i)->toSwitch();
        if ( netElement->isRouter() )
            continue;


        Elements adjacentElements = netElement->adjacentNodes();
        while( !adjacentElements.empty() ) {
            Element * pivot = *(adjacentElements.begin());
            adjacentElements.erase(pivot); 
	    
	    /*
		//find link switch-pivot and switch-anchor
		//fake link will have thoughput = 
		min{ throughput switch-pivot, throughput switch-anchor }
		*/
	    //
	    //find link switch-pivot
            Element * link_switch_to_pivot = 0;
	    Elements switch_adjacent_edges = netElement->adjacentEdges();
	    for ( Elements::iterator e = switch_adjacent_edges.begin(); e != switch_adjacent_edges.end(); e++ ) {
		if ( (*e)->toEdge()->connects( netElement ) && (*e)->toEdge()->connects( pivot ) ) {
			link_switch_to_pivot = *e;
			break;
		}
	    }
	    //
	    
	    for (Elements::iterator a = adjacentElements.begin(); a != adjacentElements.end(); a++) {
                Element * anchor = *a;
                Link * fake = getFakeLink(pivot, anchor);
		
		//
		//find link switch-anchor
		Element * link_switch_to_anchor = 0;
		for ( Elements::iterator e = switch_adjacent_edges.begin(); e != switch_adjacent_edges.end(); e++ ) {
			if ( (*e)->toEdge()->connects( netElement ) && (*e)->toEdge()->connects( anchor ) ) {
				link_switch_to_anchor = *e;
				break;
			}
		}
		uint th1 = link_switch_to_pivot->toLink()->getThroughput();
		uint th2 = link_switch_to_anchor->toLink()->getThroughput();
		fake->setThroughput( th1 > th2 ? th2 : th1 );
		//
                
                fakeRequest->addExternalLink(fake);
            }
        } 

        Elements adjacentEdges = netElement->adjacentEdges();
        for (Elements::iterator e = adjacentEdges.begin(); e != adjacentEdges.end(); e++) {
            Link * link = (*e)->toLink();
            Port * port = link->getFirst();
            port->getParentNode()->toNode()->removePort(port);
            port = link->getSecond();
            port->getParentNode()->toNode()->removePort(port); 
            fakeRequest->omitElement(link);
        } 
        fakeRequest->omitElement(netElement);
    }
    printf("Faking request: %d elements against %d in the original\n", fakeRequest->size(), r->size());
    return fakeRequest;
}
开发者ID:andxeg,项目名称:DataCenterSheduler,代码行数:67,代码来源:preprocessor.cpp


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