本文整理汇总了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;
}