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


C++ Router::updateNeighborDisconnectRouter方法代码示例

本文整理汇总了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);
  }
}
开发者ID:ianwalker2036,项目名称:cpp_coursework,代码行数:49,代码来源:router.cpp


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