本文整理汇总了C++中Router::updateNeighborDisconnectRouter方法的典型用法代码示例。如果您正苦于以下问题:C++ Router::updateNeighborDisconnectRouter方法的具体用法?C++ Router::updateNeighborDisconnectRouter怎么用?C++ Router::updateNeighborDisconnectRouter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::updateNeighborDisconnectRouter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateNeighborDisconnectRouter
/* --------------------------------------------------------------------------- */
void Router::updateNeighborDisconnectRouter(int num_router1, int num_router2) {
// The process is carried out for each neighbor of the calling Router's
// neighbor table. The calling Router will already have been updated of the
// disconnection.
for (multimap<int, Router *>::iterator ri = (this->neighborRouters).begin();
ri != (this->neighborRouters).end();
ri++)
{
Router *r = ri->second;
int count = 0; // count tracks the number of deletions that occur.
for (multimap<int, vector<int> >::iterator i = (r->routeMap).begin();
i != r->routeMap.end();)
{
multimap<int, vector<int> >::iterator erase_i = i;
i++;
// This loop deletes an entry from the routeMap if it contains the
// connection (router1, router2) or (router2, router1).
int prev_num = -999;
vector<int> v = erase_i->second;
for (vector<int>::iterator vi = v.begin();
vi != v.end() -1;
vi++)
{
if (((num_router1 == *vi) && (num_router2 == prev_num)) ||
((num_router2 == *vi) && (num_router1 == prev_num)))
{
(r->routeMap).erase(erase_i);
count++;
break; // Once a connection instance is found and route deleted,
// should break from the loop.
}
prev_num = *vi;
}
}
// If no such connections were found in any entry of the routeMap, then
// end the funciton call. This provides a base case for the recursion, so
// the method terminates.
if (count == 0) {
return;
}
// Call the function on the current Router pointed to by r.
r->updateNeighborDisconnectRouter(num_router1, num_router2);
}
}