本文整理汇总了C++中MinHeap::Pop方法的典型用法代码示例。如果您正苦于以下问题:C++ MinHeap::Pop方法的具体用法?C++ MinHeap::Pop怎么用?C++ MinHeap::Pop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MinHeap
的用法示例。
在下文中一共展示了MinHeap::Pop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
MaxHeap<int> mh;
mh.Push(3);
mh.Push(4);
mh.Push(8);
mh.Push(1);
mh.Push(9);
for (int i = 0; i < mh.Size(); ++i) {
std::cout << mh[i] << " ";
}
std::cout << std::endl;
std::cout << "==========" << std::endl;
std::cout << mh.Pop() << std::endl;
for (int i = 0; i < mh.Size(); ++i) {
std::cout << mh[i] << " ";
}
std::cout << std::endl;
std::cout << "==========" << std::endl;
MinHeap<int> minH;
minH.Push(3);
minH.Push(4);
minH.Push(8);
minH.Push(1);
minH.Push(9);
for (int i = 0; i < minH.Size(); ++i) {
std::cout << minH[i] << " ";
}
std::cout << std::endl;
std::cout << minH.Pop() << std::endl;
for (int i = 0; i < minH.Size(); ++i) {
std::cout << minH[i] << " ";
}
std::cout << std::endl;
std::cout << "---" << std::endl;
std::cout << re(3, 4) << std::endl;
std::vector<int> A{3, 6, 5};
A.pop_back();
for (auto &it : A) {
std::cout << it << std::endl;
}
std::cout << A.front() << "," << A.size() << std::endl;
return 0;
}
示例2: main
//.........这里部分代码省略.........
int offIdx = yInd * rangeX + xInd;
if (gridMap[offIdx].coords.distanceXY(firstPos) > 0.4 && gridMap[offIdx].coords.distanceXY(camPosition) > 0.3)
{
gridMap[offIdx].occupied = true;
}
}
}
}
}
}
}
cout << "Second" << endl;
cout << rangeX << ", " << rangeY << " : " << int((origin.x() - minX) * rFactor) << ", " << int((origin.y() - minY) * rFactor) << endl;
int origIdx = rangeX * int((origin.y() - minY) / res) + int((origin.x() - minX) / res);
//round(((origin.y() - minY) * rFactor) * rangeX + (origin.x() - minX) * rFactor);
cout << origIdx << " " << gridMap.size() << endl;
GridNode* originNode = &gridMap[origIdx];
originNode->cost = 0;
cout << "Got Here" << endl;
MinHeap heapy;
heapy.Push(originNode);
while (heapy.GetLength() > 0)
{
GridNode* minNode = heapy.Pop();
vector<float>::iterator edgeIt = minNode->edges.begin();
for (vector<GridNode*>::iterator iter = minNode->neighbors.begin(); iter != minNode->neighbors.end(); iter++, edgeIt++)
{
GridNode* nodePt = *iter;
if ((*iter)->occupied == 0 && (*iter)->cost > (minNode->cost + *edgeIt))
{
(*iter)->parent = minNode;
if ((*iter)->state == 0)
{
(*iter)->cost = minNode->cost + *edgeIt;
heapy.Push((*iter));
(*iter)->state = 1;
}
else if ((*iter)->state == 1)
{
heapy.Update((*iter)->heapIdx, minNode->cost + *edgeIt);
}
}
}
}
cout << "Dijkstra Path Complete" << endl;
nav_msgs::OccupancyGrid grid;
grid.header.stamp = ros::Time::now();
grid.header.frame_id = "vicon";
nav_msgs::MapMetaData metas;
metas.resolution = res;
metas.origin.position.x = minX;