本文整理汇总了C++中CkVec::quickSort方法的典型用法代码示例。如果您正苦于以下问题:C++ CkVec::quickSort方法的具体用法?C++ CkVec::quickSort怎么用?C++ CkVec::quickSort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CkVec
的用法示例。
在下文中一共展示了CkVec::quickSort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: numUniqNodes
// return -1 when not supported
int numUniqNodes() {
#if 0
if (numNodes != 0) return numNodes;
int n = 0;
for (int i=0; i<CmiNumPes(); i++)
if (nodeIDs[i] > n)
n = nodeIDs[i];
numNodes = n+1;
return numNodes;
#else
if (numNodes > 0) return numNodes; // already calculated
CkVec<int> unodes;
int i;
for (i=0; i<numPes; i++) unodes.push_back(nodeIDs[i]);
//unodes.bubbleSort(0, numPes-1);
unodes.quickSort();
int last = -1;
std::map<int, int> nodemap; // nodeIDs can be out of range of [0,numNodes]
for (i=0; i<numPes; i++) {
if (unodes[i] != last) {
last=unodes[i];
nodemap[unodes[i]] = numNodes;
numNodes++;
}
}
if (numNodes == 0) {
numNodes = CmiNumNodes();
numPes = CmiNumPes();
}
else {
// re-number nodeIDs, which may be necessary e.g. on BlueGene/P
for (i=0; i<numPes; i++) nodeIDs[i] = nodemap[nodeIDs[i]];
CpuTopology::supported = 1;
}
return numNodes;
#endif
}