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


C++ Nodes类代码示例

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


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

示例1: expand

int UltimateTicTacToeMontecarloAI::expand(int leafIndex, Nodes& nodes, int const player) const
{
  Node& node = nodes[leafIndex];
  node.children.reserve(maxChildren);
  Moves options = movementOptions(node.board, node.previousMove);
  int turn = node.previousMove > 0 ? otherPlayer(node.board.grids.at(node.previousMove)) : player;

  int mostPromisingChildIndex = -1;
  int mostPromisingChildScore = 0;

  while(node.children.size() < maxChildren && !options.empty())
  {
    Move move = options.takeAt(qrand() % options.size());
    int childIndex = nodes.size();
    node.children.append(childIndex);
    Board newBoard(node.board);
    nodes.append( Node {0, 1, playMove(newBoard, move, turn), move, leafIndex, Node::Children()});
    int score = scoreBoard(nodes.last().board, player);
    if(score > mostPromisingChildScore || mostPromisingChildIndex < 0)
    {
      mostPromisingChildIndex = childIndex;
      mostPromisingChildScore = score;
    }
  }

  return mostPromisingChildIndex;
}
开发者ID:bzar,项目名称:ultimate-tic-tac-toe,代码行数:27,代码来源:ultimatetictactoemontecarloai.cpp

示例2: EQASSERT

//----------------------------------------------------------------------
// Connecting a node
//----------------------------------------------------------------------
NodePtr LocalNode::connect( const NodeID& nodeID )
{
    EQASSERT( nodeID != NodeID::ZERO );
    EQASSERT( _state == STATE_LISTENING );

    Nodes nodes;
    getNodes( nodes );

    for( Nodes::const_iterator i = nodes.begin(); i != nodes.end(); ++i )
    {
        NodePtr peer = *i;
        if( peer->getNodeID() == nodeID && peer->isConnected( )) // early out
            return peer;
    }

    for( Nodes::const_iterator i = nodes.begin(); i != nodes.end(); ++i )
    {
        NodePtr peer = *i;
        NodePtr node = _connect( nodeID, peer );
        if( node.isValid( ))
            return node;
    }
        
    EQWARN << "Node " << nodeID << " connection failed" << std::endl;
    return 0;
}
开发者ID:MichaelVlad,项目名称:Equalizer,代码行数:29,代码来源:localNode.cpp

示例3: getAvailableNodeAssignments

void VirtualMachinesAssigner::getAvailableNodeAssignments(Element* element, std::map<Node*, std::vector<Node*> >& VMsOnNode, std::map<Node*, Assignment* >& vmAssignment, Assignment* assignment)
{
    Nodes::iterator nodesIt = network->getNodes().begin();
    Nodes::iterator nodesItEnd = network->getNodes().end();
    for ( ; nodesIt != nodesItEnd; ++nodesIt )
    {
        // inserting only vms with capacity less then the element's one
        VMsOnNode[*nodesIt] = std::vector<Node *>();

        // going through all other assigned requests
        RequestAssignment::iterator it = requestAssignment.begin();
        RequestAssignment::iterator itEnd = requestAssignment.end();
        for ( ; it != itEnd; ++it )
        {
            Nodes vms = it->second->GetAssigned(*nodesIt);
            Nodes::iterator vmIt = vms.begin();
            Nodes::iterator vmItEnd = vms.end();
            for ( ; vmIt != vmItEnd; ++vmIt )
            {
                VMsOnNode[*nodesIt].push_back(*vmIt);
                vmAssignment[*vmIt] = it->second;
            }
        }
    }
}
开发者ID:MargaritaShakhova,项目名称:DataCenters,代码行数:25,代码来源:virtualMachinesAssigner.cpp

示例4: buildElements

Elements Region::buildElements(Nodes& Base)
{
	Elements Result;
	if(typ==1)
	{
		if(numofrows<=numofcols)
		{
			for(int i=0;i<numofcols;i++)
				for(int j=0;j<numofrows;j++)
				{
					Result.push_back(Triangle(Base,i*(numofrows+1)+j,i*(numofrows+1)+j+1,(i+1)*(numofrows+1)+j),Element(i*(numofrows+1)+j,i*(numofrows+1)+j+1,(i+1)*(numofrows+1)+j));
					Result.push_back(Triangle(Base,i*(numofrows+1)+j+1,(i+1)*(numofrows+1)+j+1,(i+1)*(numofrows+1)+j),Element(i*(numofrows+1)+j+1,(i+1)*(numofrows+1)+j+1,(i+1)*(numofrows+1)+j));
					if(i==0&&CONDLEFT) Result.addcondition(Border(true,j,j+1,Base.node(j),Base.node(j+1),ENV_TEMPLEFT));
					if(i==numofcols-1&&CONDRIGHT) Result.addcondition(Border(true,(numofcols)*(numofrows+1)+j,(numofcols)*(numofrows+1)+j+1,Base.node((numofcols)*(numofrows+1)+j),Base.node((numofcols)*(numofrows+1)+j+1),ENV_TEMPRIGHT));
					if(j==0&&CONDDOWN) Result.addcondition(Border(true,(i)*(numofrows+1)+j,(i+1)*(numofrows+1)+j,Base.node((i)*(numofrows+1)+j),Base.node((i+1)*(numofrows+1)+j),ENV_TEMPDOWN));
					if(j==numofrows-1&&CONDUP) Result.addcondition(Border(true,(i)*(numofrows+1)+j+1,(i+1)*(numofrows+1)+j+1,Base.node((i)*(numofrows+1)+j+1),Base.node((i+1)*(numofrows+1)+j+1),ENV_TEMPUP));
				}
		}
		else
		{
			for(int j=0;j<numofrows;j++)
				for(int i=0;i<numofcols;i++)
				{
					Result.push_back(Triangle(Base,j*(numofcols+1)+i,j*(numofcols+1)+i+1,(j+1)*(numofcols+1)+i),Element(j*(numofcols+1)+i,j*(numofcols+1)+i+1,(j+1)*(numofcols+1)+i));
					Result.push_back(Triangle(Base,j*(numofcols+1)+i+1,(j+1)*(numofcols+1)+i+1,(j+1)*(numofcols+1)+i),Element(j*(numofcols+1)+i+1,(j+1)*(numofcols+1)+i+1,(j+1)*(numofcols+1)+i));
					if(j==0&&CONDDOWN) Result.addcondition(Border(true,i,i+1,Base.node(i),Base.node(i+1),ENV_TEMPDOWN));
					if(j==numofrows-1&&CONDUP) Result.addcondition(Border(true,(numofrows)*(numofcols+1)+i,(numofrows)*(numofcols+1)+i+1,Base.node((numofrows)*(numofcols+1)+i),Base.node((numofrows)*(numofcols+1)+i+1),ENV_TEMPUP));
					if(i==0&&CONDLEFT) Result.addcondition(Border(true,(j)*(numofcols+1)+i,(j+1)*(numofcols+1)+i,Base.node((j)*(numofcols+1)+i),Base.node((j+1)*(numofcols+1)+i),ENV_TEMPLEFT));
					if(i==numofcols-1&&CONDRIGHT) Result.addcondition(Border(true,(j)*(numofcols+1)+i+1,(j+1)*(numofcols+1)+i+1,Base.node((j)*(numofcols+1)+i+1),Base.node((j+1)*(numofcols+1)+i+1),ENV_TEMPRIGHT));
				}
		}
	}
	return Result;
}
开发者ID:vitaliygor,项目名称:HeatDistribution,代码行数:34,代码来源:elem.cpp

示例5: setMarked

void
LineMerger::buildEdgeStringsForUnprocessedNodes()
{
#if GEOS_DEBUG
	cerr<<__FUNCTION__<<endl;
#endif
	typedef std::vector<Node*> Nodes;

	Nodes nodes;
	graph.getNodes(nodes);
	for (Nodes::size_type i=0, in=nodes.size(); i<in; ++i) {
		Node *node=nodes[i];
#if GEOS_DEBUG
		cerr<<"Node "<<i<<": "<<*node<<endl;
#endif
		if (!node->isMarked()) { 
			assert(node->getDegree()==2);
			buildEdgeStringsStartingAt(node);
			node->setMarked(true);
#if GEOS_DEBUG
			cerr<<" setMarked(true) : "<<*node<<endl;
#endif
		}
	}
}
开发者ID:h4ck3rm1k3,项目名称:geos,代码行数:25,代码来源:LineMerger.cpp

示例6: Compute

    static void Compute(Nodes &nodes, AccSubAlgorithm accSubAlgorithm, AccTest *accTest)
    {
#ifdef ACCSUB_TRACE
        Timer::TimeStamp("ComputationsParallelOMP start");
        Timer::Time start = Timer::Now();
        if (accSubAlgorithm == AccSubAlgorithm::AccSubIG)
        {
            std::cout<<"using AccSubIG"<<std::endl;
        }
        else
        {
            std::cout<<"using AccSubST"<<std::endl;
        }
#endif
        #pragma omp parallel for
        for (typename Nodes::iterator i = nodes.begin(); i != nodes.end(); i++)
        {
            ComputationsLocal<PartitionGraph>::CreateIncidenceGraph(*i, accSubAlgorithm, accTest);
#ifdef ACCSUB_TRACE
            Timer::TimeStamp("incidence graph calculated");
#endif
        }
#ifdef ACCSUB_TRACE
        Timer::TimeStamp("ComputationsParallelOMP end");
        Timer::TimeFrom(start, "total distributed computations");
#endif
    }
开发者ID:pbrendel,项目名称:AccSub,代码行数:27,代码来源:ComputationsParallelOMP.hpp

示例7: buildnodes

Nodes Region::buildnodes()
{
	Nodes Result;
	srand(unsigned(time(0)));
	if(typ==1)
	{
		double steph=double(PIXELSH)/numofrows,stepw=double(PIXELSW)/numofcols;
		if(numofrows<=numofcols)
		{
			for(int i=0;i<=numofcols;i++)
				for(int j=0;j<=numofrows;j++)
					//Result.push_back(Point(stepw*i,steph*j),sqrt(stepw*i*stepw*i+steph*j*steph*j)/PIXELSH*50-50);
					//Result.push_back(Point(stepw*i,steph*j),double(rand())/RAND_MAX*200-100);
					Result.push_back(Point(stepw*i,steph*j),0);
		}
		else
		{
			for(int j=0;j<=numofrows;j++)
				for(int i=0;i<=numofcols;i++)
					//Result.push_back(Point(stepw*i,steph*j),sqrt(stepw*i*stepw*i+steph*j*steph*j)/PIXELSH*50-50);
					//Result.push_back(Point(stepw*i,steph*j),double(rand())/RAND_MAX*200-100);
					Result.push_back(Point(stepw*i,steph*j),0);
		}
	}
	return Result;
}
开发者ID:vitaliygor,项目名称:HeatDistribution,代码行数:26,代码来源:elem.cpp

示例8: EQ_TS_NOT_THREAD

//---------------------------------------------------------------------------
// identifier master node mapping
//---------------------------------------------------------------------------
NodeID ObjectStore::_findMasterNodeID( const base::UUID& identifier )
{
    EQ_TS_NOT_THREAD( _commandThread );

    // OPT: look up locally first?
    Nodes nodes;
    _localNode->getNodes( nodes );
    
    // OPT: send to multiple nodes at once?
    for( Nodes::iterator i = nodes.begin(); i != nodes.end(); i++ )
    {
        NodePtr node = *i;
        EQLOG( LOG_OBJECTS ) << "Finding " << identifier << " on " << node
                             << std::endl;

        NodeFindMasterNodeIDPacket packet;
        packet.requestID = _localNode->registerRequest();
        packet.identifier = identifier;
        node->send( packet );

        NodeID masterNodeID = base::UUID::ZERO;
        _localNode->waitRequest( packet.requestID, masterNodeID );
        if( masterNodeID != base::UUID::ZERO )
        {
            EQLOG( LOG_OBJECTS ) << "Found " << identifier << " on "
                                 << masterNodeID << std::endl;
            return masterNodeID;
        }
    }

    return base::UUID::ZERO;
}
开发者ID:MichaelVlad,项目名称:Equalizer,代码行数:35,代码来源:objectStore.cpp

示例9: if

void Apta::generateData()
{
    Q nodeIds;
    Fp acceptedNodes;
    Fm rejectedNodes;

    Nodes allNodes;
    allNodes.insert(this->_redNodes.begin(), this->_redNodes.end());
    allNodes.insert(this->_blueNodes.begin(), this->_blueNodes.end());
    allNodes.insert(this->_whiteNodes.begin(), this->_whiteNodes.end());

    for (pair<string, string> node : allNodes) {
        if (node.second == Apta::ACCEPTED) {
            acceptedNodes.insert(node.first);
        } else if (node.second == Apta::REJECTED) {
            rejectedNodes.insert(node.first);
        }
        nodeIds.insert(node.first);
    }

    this->_data.Q = nodeIds;
    this->_data.Z = this->_alphabet;
    this->_data.s = this->_rootId;
    this->_data.Fp = acceptedNodes;
    this->_data.Fm = rejectedNodes;
}
开发者ID:grammarhoard,项目名称:2014-rosu-inference-cpp,代码行数:26,代码来源:Apta.cpp

示例10: loadAll

    QObjectList loadAll(NodeObjectMap &map) {
        
        Nodes nodes;
        
        Triples candidates = m_s->match(Triple(Node(), Uri("a"), Node()));
        foreach (Triple t, candidates) {
            if (t.c.type != Node::URI) continue;
            nodes.push_back(t.a);
        }

        LoadState state;
        state.requested = nodes;
        state.map = map;
        state.loadFlags = LoadState::IgnoreUnknownTypes;

        collect(state);
        load(state);

        map = state.map;

        QObjectList objects;
        foreach (Node n, nodes) {
            QObject *o = map.value(n);
            if (o) objects.push_back(o);
        }
开发者ID:breakfastquay,项目名称:dataquay,代码行数:25,代码来源:ObjectLoader.cpp

示例11: checkDesired

static bool checkDesired(vpsc::Dim dim, const Nodes& nodes,
        const Rectangles& targets, const ResizeMap& resizeMap)
{
    for (Nodes::const_iterator i=nodes.begin();i!=nodes.end();++i) {
        const Node* v=*i;
        const unsigned id=v->id;
        const Rectangle* t=targets[id];
        ResizeMap::const_iterator j=resizeMap.find(id);
        if(j==resizeMap.end()) {
            COLA_ASSERT(approx_equals(v->var->desiredPosition,
                        t->getCentreD(dim)));
        }
    }
    for(ResizeMap::const_iterator j=resizeMap.begin();j!=resizeMap.end();++j) {
        const unsigned id=j->first;
        const ResizeInfo& ri=j->second;
        COLA_ASSERT(ri.orig->id==id);
        const Node *ln=ri.lhsNode, *cn=nodes[id], *rn=ri.rhsNode;
        COLA_ASSERT(ln->id==id);
        COLA_ASSERT(cn->id==id);
        COLA_ASSERT(rn->id==id);
        const Rectangle* t=targets[id];
        const double lp = t->getMinD(dim) + DW2,
                     cp = t->getCentreD(dim),
                     rp = t->getMaxD(dim) - DW2;
        COLA_ASSERT(approx_equals(lp,ln->var->desiredPosition));
        COLA_ASSERT(approx_equals(cp,cn->var->desiredPosition));
        COLA_ASSERT(approx_equals(rp,rn->var->desiredPosition));
    }
    return true;
}
开发者ID:SiteView,项目名称:NNMQT,代码行数:31,代码来源:resize.cpp

示例12: PrintNodes

 static void PrintNodes(std::ostream &str, const Nodes &nodes)
 {
     for (typename Nodes::const_iterator i = nodes.begin(); i != nodes.end(); i++)
     {
         PrintSimplex(str, (*i)->simplex);
     }
 }
开发者ID:pbrendel,项目名称:AccSub,代码行数:7,代码来源:Utils.hpp

示例13: closure

bool TypeHierarchy::closure(Graph & gr,GI & gi,Nodes & vs,GI & gs,const TypeRef * t)
{	 
	if(gi == gr.end()) 
	{
		return false;
	};
	if(*(gi->first) == *t) 
	{
		for(Nodes::const_iterator i = vs.begin();i != vs.end();++i)
		{
			gs->second.insert(*i);
			//insert(vs.begin(),vs.end());
		};
		//gs->second.insert(vs.begin(),vs.end());
		return true;
	};

	for(Nodes::iterator n = gi->second.begin();n != gi->second.end();++n)
	{
		if(vs.find(*n) == vs.end())
		{
			vs.insert(*n);
			GI tmp = gr.find(*n);
			if(closure(gr,tmp,vs,gs,t)) return true;
		};
	};
	return false;
};
开发者ID:mdrichar,项目名称:POGDDL,代码行数:28,代码来源:typecheck.cpp

示例14: getNodes

void Config::_stopNodes()
{
    // wait for the nodes to stop, destroy entities, disconnect
    Nodes stoppingNodes;
    const Nodes& nodes = getNodes();
    for( Nodes::const_iterator i = nodes.begin(); i != nodes.end(); ++i )
    {
        Node* node = *i;
        const State state = node->getState();
        if( state != STATE_STOPPED && state != STATE_FAILED )
            continue;

        LBASSERT( !node->isActive() || state == STATE_FAILED );
        if( node->isApplicationNode( ))
            continue;

        co::NodePtr netNode = node->getNode();
        if( !netNode ) // already disconnected
            continue;

        LBLOG( LOG_INIT ) << "Exiting node" << std::endl;

        if( state == STATE_FAILED )
            node->setState( STATE_STOPPED );

        stoppingNodes.push_back( node );
        LBASSERT( netNode.isValid( ));

        netNode->send( fabric::CMD_SERVER_DESTROY_CONFIG )
                << getID() << LB_UNDEFINED_UINT32;
        netNode->send( fabric::CMD_CLIENT_EXIT );
    }

    // now wait that the render clients disconnect
    uint32_t nSleeps = 50; // max 5 seconds for all clients
    for( Nodes::const_iterator i = stoppingNodes.begin();
         i != stoppingNodes.end(); ++i )
    {
        Node*        node    = *i;
        co::NodePtr netNode = node->getNode();
        node->setNode( 0 );

        if( nSleeps )
            while( netNode->isConnected() && --nSleeps )
                lunchbox::sleep( 100 ); // ms

        if( netNode->isConnected( ))
        {
            co::LocalNodePtr localNode = getLocalNode();
            LBASSERT( localNode.isValid( ));

            LBWARN << "Forcefully disconnecting exited render client node"
                   << std::endl;
            localNode->disconnect( netNode );
        }

        LBLOG( LOG_INIT ) << "Disconnected node" << std::endl;
    }
}
开发者ID:hernando,项目名称:Equalizer,代码行数:59,代码来源:config.cpp

示例15: count_per_qid

int Test::count_per_qid(const Nodes& nodes, const Qid& qid) const
{
	int count = 0;
	for (Nodes::const_iterator ni = nodes.begin(); ni != nodes.end(); ++ni) {
		if (ni->qid == qid) ++count;
	}
	return count;
}
开发者ID:nrmnr,项目名称:auto_select_test,代码行数:8,代码来源:test.cpp


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