本文整理汇总了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++);
}
}
示例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) */
}
示例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--;
}
}
}
示例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; }
}
}
示例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);
}
示例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;
}
}
}