本文整理汇总了C++中std::vector::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::remove方法的具体用法?C++ vector::remove怎么用?C++ vector::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::vector
的用法示例。
在下文中一共展示了vector::remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove_entity
void remove_entity( const T& ent ) {
all_entities.remove( ent );
}
示例2: CalculatePathFromXYtoXY
GMEXPORT double CalculatePathFromXYtoXY(double x1, double y1, double x2, double y2)
{
if (x1 != x2 || y1 != y2)
{
m_PathList.clear();
std::map<int, std::map<int, MapSearchNode*> > grid;
for (int i = 0; i < 42; i++)
{
for (int j = 0; j < 34; j++)
{
grid[i][j] = new MapSearchNode();
grid[i][j]->x = i;
grid[i][j]->y = j;
}
}
ofstream fileStream;
fileStream.open("level_paths.txt");
// define the new nodes
MapSearchNode* start = new MapSearchNode();
start->x = x1;
start->y = y1;
fileStream << "START";
fileStream << " START X: ";
fileStream << start->x;
fileStream << " START Y: ";
fileStream << start->y;
MapSearchNode* end = new MapSearchNode();
end->x = x2;
end->y = y2;
fileStream << "END";
fileStream << " END X: ";
fileStream << end->x;
fileStream << " END Y: ";
fileStream << end->y;
MapSearchNode* current = new MapSearchNode();
MapSearchNode* child = new MapSearchNode();
std::list<MapSearchNode*> openList;
std::list<MapSearchNode*> closedList;
list<MapSearchNode*>::iterator i;
unsigned int n = 0;
openList.push_back(start);
start->opened = true;
while (n == 0 || (current != end && n < 50))
{
// Look for the smallest f value in the openList
for (i = openList.begin(); i != openList.end(); i++)
{
if (i == openList.begin() || (*i)->GetFScore() <= current->GetFScore())
{
current = (*i);
}
}
fileStream << "searching";
fileStream << " Current X: ";
fileStream << current->x;
fileStream << " Current Y: ";
fileStream << current->y;
// Stop if we've reached the end
if (current->x == end->x && current->y == end->y)
{
fileStream << "end reached";
break;
}
// Remove the current point from the open list
openList.remove(current);
current->opened = false;
// Add the current point from the open list
closedList.push_back(current);
current->closed = true;
// Get all the current adjacent walkable points
for (int x = -1; x < 2; x++)
{
for (int y = -1; y < 2; y++)
{
if (x == 0 && y == 0)
{
// ignore current node, pass
continue;
}
if (x == 0 || y == 0)
{
child = grid[current->x + x][current->y + y];
//.........这里部分代码省略.........