本文整理汇总了C++中MinHeap::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ MinHeap::GetLength方法的具体用法?C++ MinHeap::GetLength怎么用?C++ MinHeap::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MinHeap
的用法示例。
在下文中一共展示了MinHeap::GetLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
if (xInd >= 0 && xInd < rangeX && yInd >= 0 && yInd < rangeY)
{
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;