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


C++ ObjectList::erase方法代码示例

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


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

示例1: filterCurSelectedObjects

void Player::filterCurSelectedObjects(ObjectList &selected_objs, int select_cnt_limit) const
{
	int stats[ObjectType::SIZE] = {0, };
	int my_unit_cnt = 0;
	for(ObjectList::const_iterator it = selected_objs.begin(); 
		it != selected_objs.end(); ++it)
	{
		const ObjectPtr &obj = *it;
		stats[obj->getObjectType()]++;
		if(obj->getOwner() == this)
			my_unit_cnt++;
	}

	for(ObjectList::iterator it = selected_objs.begin(); 
		it != selected_objs.end(); )
	{
		const ObjectPtr &obj = *it;
		
		// if there are at least one selected unit, deselect non-unit objects.
		if(stats[ObjectType::Unit] > 0)
		{
			if(obj->getObjectType() != ObjectType::Unit)
				selected_objs.erase(it++);
			else
				++it;
		}
		else if(my_unit_cnt != 0)
		{
			if(obj->getOwner() != this)
				selected_objs.erase(it++);
			else
				++it;
		}
		else
		{
			++it;
		}
	} /* for(ObjectList::iterator it = selected_objs.begin(); */
	
	if(select_cnt_limit > 0)
	{
		ObjectList::iterator end = selected_objs.end();
		ObjectList::iterator it = selected_objs.begin();
		
		// skip first nth object
		for(int i = 0; i < select_cnt_limit && it != end; i++)
			++it;
		
		// erase everything else
		while(it != end)
			selected_objs.erase(it++);
	}
}
开发者ID:pjm0616,项目名称:juchecraft,代码行数:53,代码来源:Player.cpp

示例2: mergeObjectList

void Player::mergeObjectList(ObjectList &orig, const ObjectList &newobjs, SelectionFlags_t flags)
{
	if(flags == SelectionFlags::SET)
	{
		orig = newobjs;
	}
	else if(flags == SelectionFlags::ADD)
	{
		for(ObjectList::const_iterator it = newobjs.begin(); it != newobjs.end(); ++it)
		{
			ObjectList::const_iterator it2 = std::find(orig.begin(), orig.end(), *it);
			if(it2 == orig.end())
				orig.addObject(*it);
		}
	} /* else if(flags == SelectionFlags::ADD) */
	else if(flags == SelectionFlags::REMOVE)
	{
		for(ObjectList::const_iterator it = newobjs.begin(); it != newobjs.end(); ++it)
		{
			ObjectList::iterator it2 = std::find(orig.begin(), orig.end(), *it);
			if(it2 != orig.end())
				orig.erase(it2);
		}
	} /* else if(flags == SelectionFlags::REMOVE) */
}
开发者ID:pjm0616,项目名称:juchecraft,代码行数:25,代码来源:Player.cpp

示例3: InsertAndRemoveDuplicates

void Object::InsertAndRemoveDuplicates(ObjectList& set,
					      int old)  {
  cout << "******* Object::InsertAndRemoveDuplicates() " << endl;
  // This _is_ still used by Query::GatherNewObjects() by CombineMapsVQ().
  // I think no place uses this nomore.  Should be obsoleted ???

  for (size_t i=old; i<set.size(); i++) {
    size_t p = i, q = i;
    double val = set[i].Value();
    for (int j=old-1; j>=0; j--) {
      if (val>set[j].Value())
	p = j;
      else if (q!=i)
	break;
      if (q==i && set[j].Match(set[i])) {
	val = set[j].AddValue(val);  // OBS! AddValue()
	p = q = j;
      }
    }
    set.move(q, p);
    if (q==i)
      old++;
    else {
      set.swap_objects(i, set.size()-1);
      set.erase(set.size()-1);
      i--;
    }
  }
}
开发者ID:aalto-cbir,项目名称:PicSOM,代码行数:29,代码来源:Valued.C

示例4: excludeByType

void excludeByType( ObjectList& list, const Set& set )
{
  for( auto it=list.begin(); it != list.end(); )
  {
    if( set.count( (*it)->type() ) > 0 ) { it=list.erase( it ); }
    else { ++it; }
  }
}
开发者ID:binakot,项目名称:caesaria-game,代码行数:8,代码来源:common.hpp

示例5: dtDeleteObject

void dtDeleteObject(DtObjectRef object) {
  ObjectList::iterator i = objectList.find(object);
  if (i != objectList.end()) {
    if (currentObject == (*i).second) currentObject = 0;
    delete (*i).second;
    objectList.erase(i);
  }
  respTable.cleanObject(object);
}
开发者ID:UWEcoCAR,项目名称:car-simulator,代码行数:9,代码来源:C-api.cpp

示例6: removeGridObject

void DataManager::removeGridObject(int x, int y, ObjectPtr object) {
	CellData* cd = &GET_GRID_ITEM(grid,x,y);
	ObjectList* objects = &cd->objects;
	for (ObjectList::iterator it = objects->begin(); it != objects->end(); it++) {
		if (*it == object) {
			objects->erase(it);
			gridChanged(x, y, cd);
			break;
		}
	}
}
开发者ID:cheesecakenl,项目名称:git-c-plusplus,代码行数:11,代码来源:DataManager.cpp


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