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


C++ AStarNode::del_parent方法代码示例

本文整理汇总了C++中AStarNode::del_parent方法的典型用法代码示例。如果您正苦于以下问题:C++ AStarNode::del_parent方法的具体用法?C++ AStarNode::del_parent怎么用?C++ AStarNode::del_parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AStarNode的用法示例。


在下文中一共展示了AStarNode::del_parent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: delete_node

/* 
* Remove a parent from a node and delete it if it runs out of parents
* @param pos: The position of the node to remove
* @param parent_pos: The parent of the position to remove
* (only remove a position/parent combo)
* @param del_mem: True if the node should be deleted here, false if it should
* simply be marked for deletion (so the OPEN list heap does not contain deleted nodes)
* @return 0 if the node is not found, 
* 1 if it is found but not deleted, 2 if it is found and deleted
*/
int AStarNodeList::delete_node(Position* pos, Coord* parent_coord, bool del_mem)
{
	/* Find the node iterator */
	AStarNode* found = list->find(pos);

	/* Make sure the node exists */
	if (found == NULL)
		return 0;

	/* If the node has no more parents after the deletion of this parent */
	if (found->del_parent(parent_coord) == 0)
	{


	/*	Position check = Position(0, 5, 5);
		if (check == *pos)
		{
			std::cout << "PRE DELETION" << std::endl;
			print_list();
		}*/


		/* remove it from the list */
		list->erase(pos);



		/* Delete the node pointed to by the list or mark it for deletion */
		if (del_mem == true)
			delete found;
		else
			found->mark_for_deletion();

	
		/*
		if (check == *pos)
		{
			std::cout << "POST DELETION" << std::endl;
			print_list();
		}
		*/


		return 2;
	}
	/* The node was found but not deleted */
	return 1;
}
开发者ID:ahoff23,项目名称:MS_Project,代码行数:58,代码来源:AStarNodeList.cpp


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