当前位置: 首页>>代码示例>>C++>>正文


C++ vector::remove方法代码示例

本文整理汇总了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 );
	}
开发者ID:TomaszSakrejda,项目名称:musiqcWashington,代码行数:3,代码来源:spatial.hpp

示例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];
//.........这里部分代码省略.........
开发者ID:Kytie,项目名称:SpelunkBots,代码行数:101,代码来源:Spelunkbots.cpp


注:本文中的std::vector::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。