本文整理汇总了C++中NodeIterator::current方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeIterator::current方法的具体用法?C++ NodeIterator::current怎么用?C++ NodeIterator::current使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeIterator
的用法示例。
在下文中一共展示了NodeIterator::current方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
}
}
}
示例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++;
}
}
}
示例3: isNeighbor
bool LitterNetwork::isNeighbor(LitterNode& source, LitterNode& dest) {
NodeIterator* ni = source.getNeighborIT();
while (ni->moveNext()) {
if (ni->current() == &dest) {
return true;
}
}
return false;
}
示例4: ResetValid
void PFLCFG::ResetValid(void)
{
NodeIterator i = FirstNode();
for (; i != LastNode(); i++)
{
BBType *bb = i.current()->NodeInfo;
bb->Valid = false;
}
}
示例5: RemoveDeadNodes
void PFLCFG::RemoveDeadNodes(void)
{
bool changed = true;
//uint32 round = 0;
while (changed)
{
NodeIterator i = FirstNode();
changed = false;
for (; i != LastNode(); i++)
{
BBType *bb = i.current()->NodeInfo;
if (bb->Kind != BB_CFG_ENTRY && bb->Valid)
{
if (i.current()->GetPredecessors().empty())
{
changed = true;
bb->Valid = false;
}
}
}
if (changed)
{
NodeIterator i = FirstNode();
for(; i != LastNode(); i++)
{
BBType *bb = i.current()->NodeInfo;
if (!bb->Valid)
{
list<node_t*> &succ = bb->getNode()->GetSuccessors();
list<node_t*>::iterator k = succ.begin();
for (; k != succ.end(); k++)
DeleteEdge(*(*k), *bb->getNode());
//delete bb;
//Graph.DeleteNode(*i.current());
}
}
}
}
}
示例6: 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;
}