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


C++ PriorityQueue::minPrioirty方法代码示例

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


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

示例1: genNextFill

///Generate next move by taking into account the most connected cells.
///@param emptyindicators: boolean array to indicate the empty positions
///@param queue the priority queue stores the empty positions with the priority as the connections to the position adding some randomness
///@param counter the auxiliary vector which stores the index of position and priority
///@return next move represent as index or position on the hex board
int Strategy::genNextFill(hexgame::shared_ptr<bool>& emptyindicators,
                          PriorityQueue<int, int>&queue,
                          int& proportionofempty) {
  int nexloc = queue.minPrioirty();
  emptyindicators.get()[nexloc - 1] = false;
  --proportionofempty;
  return nexloc;
}
开发者ID:renewang,项目名称:HexGame,代码行数:13,代码来源:Strategy.cpp

示例2: mst

void Prim::mst(int root,Color color){
	Q.clear();
	int size=G->V();  // number of vertices
	for(int i=0;i<size;i++){
		dist[i]=1000.0;
		edges[i]=NO_EDGE;
		if(G->get_node_value(i)==color){  // only choose the same color
		    	//dist[i]=INF;    // equal to infinite
			//cout<<"insert node!"<<i<<" and dist is "<<dist[i]<<endl;
		Q.Insert(Type_Queue_Element (i,dist[i]));  // assign V[G] to Q
		}
	}
	dist[root]=0.0;
	if(!Q.contains(root)) cout<<"not include root !!"<<endl;
	else {
		Q.chgPrioirity(root,dist[root]);   //dist[i] and priority value in priority queue must be synchronized
		edges[root]=ROOT_EDGE;
		while(!Q.empty()){
			Type_Queue_Element currElement=Q.top();
            Q.minPrioirty();  // remove from priority queue
			int currNode=currElement.first;
			if(edges[currNode]!=NO_EDGE){
				dist[currNode]=currElement.second;
				vector<int> neibs=G->neighbors(currNode,color);
				for(unsigned int i=0;i<neibs.size();i++){
					if(Q.contains(neibs[i]) && (G->get_edge_value(neibs[i],currNode)<dist[neibs[i]]) ){
						edges[neibs[i]]=currNode;
						dist[neibs[i]]=G->get_edge_value(neibs[i],currNode);
						Q.chgPrioirity(neibs[i],dist[neibs[i]]);
					}
				}
			}

		}
	}
}
开发者ID:ktjones,项目名称:CPP4C_Programmers,代码行数:36,代码来源:HWFive.cpp


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