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


C++ NodeIterator::moveNext方法代码示例

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


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

示例1: send

void CheckGap::send(Node& node, int start, int end) {
  LitterNode& lnode = dynamic_cast<LitterNode&>(_node);
  LitterNode& dnode = dynamic_cast<LitterNode&>(node);

  lnode.stats.gapfound++;

  if (dnode.getOnline() == true) {
    Action* pr_event = new GapRcv(node, _node, _sched, _net,
                                    start, end, node);
    LitterNetwork& lnet = dynamic_cast<LitterNetwork&>(_net);
    lnet.send(lnode, dnode, *pr_event, _sched);
    lnode.stats.gaptx++;
  }
  else {
    NodeIterator* ni = lnode.getNeighborIT();
    while (ni->moveNext()) {
      Node* neighbor = ni->current();
      LitterNode& dest = dynamic_cast<LitterNode&>(*neighbor);
      if (dest.getOnline() == true) {
        LitterNetwork& lnet = dynamic_cast<LitterNetwork&>(_net);
        if ( lnet.isNeighbor(dnode, dest)) {
          Action* pr_event = new GapRcv(*neighbor, _node, _sched, _net,
                                          start, end, node);
          lnet.send(lnode, dest, *pr_event, _sched);
          lnode.stats.gaptx++;
          break;
        }
      }
    }
  }
}
开发者ID:pstjuste,项目名称:netmodeler,代码行数:31,代码来源:litter.cpp

示例2: Execute

void PullSend::Execute() {
  if (_resched) {
    Action* ps_event = new PullSend(_node, _sched, _net, _resched);
    _sched.after(ps_rate, ps_event);
  }

  LitterNode& lnode = dynamic_cast<LitterNode&>(_node);
  if (lnode.getOnline() == false) return;

  int end = _sched.getCurrentTime();
  int start = lnode.getLastPull();
  lnode.setLastPull(_sched.getCurrentTime());

  int delay = 0;
  NodeIterator* ni = lnode.getNeighborIT();
  while (ni->moveNext()) {
    Node* neighbor = ni->current();
    LitterNode& dest = dynamic_cast<LitterNode&>(*neighbor);
    if (dest.getOnline() == true) {
      Action* pr_event = new PullRcv(*neighbor, _node, _sched, _net, start, 
                                      end);
      LitterNetwork& lnet = dynamic_cast<LitterNetwork&>(_net);
      lnet.send(lnode, dest, *pr_event, _sched, delay++);
      lnode.stats.pulltx++;
    }
  }
}
开发者ID:pstjuste,项目名称:netmodeler,代码行数:27,代码来源:litter.cpp

示例3: isNeighbor

bool LitterNetwork::isNeighbor(LitterNode& source, LitterNode& dest) {
  NodeIterator* ni = source.getNeighborIT();
  while (ni->moveNext()) {
    if (ni->current() == &dest) {
      return true;
    }
  }
  return false;
}
开发者ID:pstjuste,项目名称:netmodeler,代码行数:9,代码来源:litter.cpp

示例4: main

int main(int argc, char* argv[]) {

  if (argc < 6) {
    cout << " usage: ./litter exp_on exp_off droprate days genrate"
         << " < graphfile\n";
    return 0;
  }

  double churn_on = atof(argv[1]);
  double churn_off = atof(argv[2]);
  double drop_rate = double(1) - atof(argv[3]);
  int days = atoi(argv[4]) + 1;
  GDays = days;
  int runtime = days * 24 * 3600;
  int genrate = atoi(argv[5]);
  int seed = -1;

  if (argc >= 8) {
    ps_rate = atoi(argv[6]);
    cg_rate = atoi(argv[7]);
  }

  Random* rnd = new Ran1Random(seed);
  EventScheduler* sched = new EventScheduler();
  Network* net = new LitterNetwork(std::cin, *rnd, drop_rate);
  ExpDRV* expon = new ExpDRV(*rnd, churn_on);
  ExpDRV* expoff = new ExpDRV(*rnd, churn_off);
  UniformNodeSelector* ns = new UniformNodeSelector(*rnd);
  ns->selectFrom(net);
  NodeIterator* ni = net->getNodeIterator();
  int time = 0;

  // Schedule a churn event for each node
  while (ni->moveNext()) {
    Node* node = ni->current();
    time = rnd->getInt(3600);
    sched->at(time, new ChurnEvent(*node, *sched, *net, *expoff, *expon));
  }

  // Schedule a pull request at each node
  ni->reset();
  while (ni->moveNext()) {
    Node* node = ni->current();
    time = rnd->getInt(3600);
    sched->at(time, new PullSend(*node, *sched, *net, true));
  }

  // Schedule a checkgap at each node
  ni->reset();
  while (ni->moveNext()) {
    Node* node = ni->current();
    time = rnd->getInt(3600);
    sched->at(time, new CheckGap(*node, *sched, *net));
  }

  // Periodically generates posts
  sched->at(1800, new PostGen(*sched, *net, *rnd, *ns,  genrate));

  // Stops the scheduler
  sched->at(runtime, new StopAction(*sched));
  sched->start();

  StatsPrint(*net, *sched);

  // clean up global objects
  delete rnd;
  delete sched;
  delete expon;
  delete expoff;
  delete net;
  delete ni;
  delete ns;

  return 0;
}
开发者ID:pstjuste,项目名称:netmodeler,代码行数:75,代码来源:litter.cpp


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