本文整理汇总了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;
}
示例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]]);
}
}
}
}
}
}