本文整理汇总了C++中std::list::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ list::erase方法的具体用法?C++ list::erase怎么用?C++ list::erase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::list
的用法示例。
在下文中一共展示了list::erase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: untrackRef
static void untrackRef(Ref* ref)
{
auto iter = std::find(__refAllocationList.begin(), __refAllocationList.end(), ref);
if (iter == __refAllocationList.end())
{
log("[memory] CORRUPTION: Attempting to free (%s) with invalid ref tracking record.\n", typeid(*ref).name());
return;
}
__refAllocationList.erase(iter);
}
示例2: FilterTargets
void FilterTargets(std::list<Unit*>& unitList)
{
for (std::list<Unit*>::iterator itr = unitList.begin(); itr != unitList.end();)
{
if ((*itr)->GetTypeId() == TYPEID_PLAYER && (*itr)->ToPlayer()->GetQuestStatus(GetSpellInfo()->Effects[EFFECT_1].CalcValue()) == QUEST_STATUS_INCOMPLETE)
++itr;
else
unitList.erase(itr++);
}
unitList.push_back(GetCaster());
}
示例3: AnalyseMsgWithWaitList
//_______________________________________________________________________________________
//Прокручивает очередь отправленных сообщений, начиная со самых старых. Если ReceivedMsg!=NULL,
//то сначала анализирует принятое сообщение на соответствие списку. Если соответствие
//найдено, выполняет действие, удаляет отправленное. Если не найдено, принимает
//асинхронное сообщение.
//Перед выходом проверяет список на таймаут (выдает сообщение и удаляет).
void CComThreadBasic::AnalyseMsgWithWaitList(std::list<ComMsg>& List, ComMsg *ReceivedMsg)
{
std::list<ComMsg>::iterator iter;
//ComMsg SentMsg;
bool Processed=false;
if(ReceivedMsg!=NULL)
{
for (iter = List.begin(); iter != List.end();)
{
if(AnalyseCorrectMsg(ReceivedMsg, &(*iter)))
{
//Сообщение обработано. Удаление задания из очереди, выход
List.erase(iter);
Processed=true;
break;
}
else
++iter;
}
if(!Processed)
{
//Прием асинхронного (неинициированного этой программой) сообщения
AnalyseCorrectMsg(ReceivedMsg, NULL);
}
}
//Проверка на таймаут
ULONG TickCount=GetTickCount();
for (iter = List.begin(); iter != List.end();)
{
if(TickCount-iter->TimeStamp>m_ReplyTimeout*1000)
{
//Таймаут.
ReportTimeOut(&(*iter));
iter=List.erase(iter);
}
else
++iter;
}
}
示例4: deleteShape
void deleteShape()
{
for (std::list<Shape>::iterator it = listOfShapes.begin(); it != listOfShapes.end(); it++)
{
if(it->shapeId == selected)
{
selected = 0;
listOfShapes.erase(it);
break;
}
}
}
示例5: connectLines
bool MeshProjection::connectLines(std::list< std::pair<Base::Vector3f, Base::Vector3f> >& cutLines,
const Base::Vector3f& startPoint, const Base::Vector3f& endPoint,
std::vector<Base::Vector3f>& polyline) const
{
const float fMaxDist = float(sqrt(FLOAT_MAX)); // max. length of a gap
const float fMinEps = 1.0e-4f;
polyline.clear();
polyline.push_back(startPoint);
Base::Vector3f curr(startPoint);
while ((curr != endPoint) && (!cutLines.empty())) {
std::list< std::pair<Base::Vector3f, Base::Vector3f> >::iterator it, pCurr = cutLines.end();
// get nearest line
float fMin = fMaxDist * fMaxDist;
bool bPos = false;
for (it = cutLines.begin(); it != cutLines.end(); ++it) {
float fD1 = Base::DistanceP2(curr, it->first);
float fD2 = Base::DistanceP2(curr, it->second);
if (std::min<float>(fD1, fD2) < fMin) {
pCurr = it;
bPos = fD1 < fD2;
fMin = std::min<float>(fD1, fD2);
if (fMin < fMinEps) // abort because next line already found
break;
}
}
if (pCurr != cutLines.end()) {
if (bPos) {
if (fMin > fMinEps) // gap, insert point
polyline.push_back(pCurr->first);
polyline.push_back(pCurr->second);
curr = pCurr->second;
}
else {
if (fMin > fMinEps) // gap, insert point
polyline.push_back(pCurr->second);
polyline.push_back(pCurr->first);
curr = pCurr->first;
}
}
else {
return false; // abort because no line was found
}
cutLines.erase(pCurr);
}
return true;
}
示例6: removeFromModified
void IPrimitiveEditor::removeFromModified ()
{
// Already inserted ?
if (_ModifiedIterator != ModifiedPrimitive.end ())
{
// Remove from the container
ModifiedPrimitive.erase (_ModifiedIterator);
// Clear it
_ModifiedIterator = ModifiedPrimitive.end ();
}
}
示例7: removeFromSelection
void IPrimitiveEditor::removeFromSelection ()
{
// Already inserted ?
if (_SelectionIterator != Selection.end ())
{
// Remove from the container
Selection.erase (_SelectionIterator);
// Clear it
_SelectionIterator = Selection.end ();
}
}
示例8: while
std::vector<int> ChowLiuTree::extractChildren(std::list<info> &remaining_edges, int q) {
std::vector<int> children;
std::list<info>::iterator edge = remaining_edges.begin();
while(edge != remaining_edges.end()) {
if(edge->word1 == q) {
children.push_back(edge->word2);
edge = remaining_edges.erase(edge);
continue;
}
if(edge->word2 == q) {
children.push_back(edge->word1);
edge = remaining_edges.erase(edge);
continue;
}
edge++;
}
return children;
}
示例9: do_register_drawable
void do_register_drawable(const std::shared_ptr<drawable>& drawable)
{
drawables_.push_back(drawable);
auto it = drawables_.begin();
while(it != drawables_.end())
{
if(it->lock())
++it;
else
it = drawables_.erase(it);
}
}
示例10: RemoveFromList
void MultiQueueMigrator::RemoveFromList(std::list<uint64_t> list, uint64_t pageNo)
{
std::list<uint64_t>::iterator iter;
for(iter = list.begin(); iter != list.end(); iter++)
{
if(pageNo == *iter)
{
list.erase(iter);
return;
}
}
}
示例11: RemoveEmptyGames
void RemoveEmptyGames() {
for (std::list<Game *>::iterator ptr(games.begin()), end(games.begin()), del; ptr != end;) {
del = ptr;
Game *g = *ptr;
++ptr;
if (g->a == 0 && g->b == 0) {
MakeDirty();
games.erase(del);
delete g;
}
}
}
示例12: wk_gateKeeper
void wk_gateKeeper(DS::SocketHandle sockp)
{
GateKeeper_Private client;
client.m_crypt = 0;
s_clientMutex.lock();
client.m_sock = sockp;
s_clients.push_back(&client);
s_clientMutex.unlock();
try {
gate_init(client);
for ( ;; ) {
uint16_t msgId = DS::CryptRecvValue<uint16_t>(client.m_sock, client.m_crypt);
switch (msgId) {
case e_CliToGateKeeper_PingRequest:
cb_ping(client);
break;
case e_CliToGateKeeper_FileServIpAddressRequest:
cb_fileServIpAddress(client);
break;
case e_CliToGateKeeper_AuthServIpAddressRequest:
cb_authServIpAddress(client);
break;
default:
/* Invalid message */
fprintf(stderr, "[GateKeeper] Got invalid message ID %d from %s\n",
msgId, DS::SockIpAddress(client.m_sock).c_str());
DS::CloseSock(client.m_sock);
throw DS::SockHup();
}
}
} catch (const DS::SockHup&) {
// Socket closed...
} catch (const std::exception& ex) {
fprintf(stderr, "[GateKeeper] Error processing client message from %s: %s\n",
DS::SockIpAddress(sockp).c_str(), ex.what());
}
s_clientMutex.lock();
auto client_iter = s_clients.begin();
while (client_iter != s_clients.end()) {
if (*client_iter == &client)
client_iter = s_clients.erase(client_iter);
else
++client_iter;
}
s_clientMutex.unlock();
DS::CryptStateFree(client.m_crypt);
DS::FreeSock(client.m_sock);
}
示例13: UpdateJoystickEvents
void UpdateJoystickEvents()
{
std::list<JoystickEvent_t*>::iterator i;
event_t event;
if(!JoyEventList.size())
return;
i = JoyEventList.begin();
while(i != JoyEventList.end())
{
if((*i)->Event.type == SDL_JOYHATMOTION)
{
// Hat position released
if(!(SDL_JoystickGetHat(openedjoy, (*i)->Event.jhat.hat) & (*i)->Event.jhat.value))
event.type = ev_keyup;
// Hat button still held - Repeat at key repeat interval
else if((SDL_GetTicks() - (*i)->RegTick >= SDL_DEFAULT_REPEAT_DELAY) &&
(SDL_GetTicks() - (*i)->LastTick >= SDL_DEFAULT_REPEAT_INTERVAL*2))
{
(*i)->LastTick = SDL_GetTicks();
event.type = ev_keydown;
}
else
{
i++;
continue;
}
event.data1 = event.data2 = event.data3 = 0;
if((*i)->Event.jhat.value == SDL_HAT_UP)
event.data1 = ((*i)->Event.jhat.hat * 4) + KEY_HAT1;
else if((*i)->Event.jhat.value == SDL_HAT_RIGHT)
event.data1 = ((*i)->Event.jhat.hat * 4) + KEY_HAT2;
else if((*i)->Event.jhat.value == SDL_HAT_DOWN)
event.data1 = ((*i)->Event.jhat.hat * 4) + KEY_HAT3;
else if((*i)->Event.jhat.value == SDL_HAT_LEFT)
event.data1 = ((*i)->Event.jhat.hat * 4) + KEY_HAT4;
D_PostEvent(&event);
if(event.type == ev_keyup)
{
// Delete the released event
delete *i;
i = JoyEventList.erase(i);
continue;
}
}
i++;
}
}
示例14: RemoveZonesAt
void RemoveZonesAt(short rzx,short rzy)
{
std::list<ZoneRef>::iterator zli;
//erase all zones in list
for(zli=zonelist.begin();zli!=zonelist.end();zli++)
if(zli->PointInZone(rzx,rzy))
zonelist.erase(zli);
//erase all zones in children's lists
for(int i=0;i<4;i++)
if(children[i])
children[i]->RemoveZonesAt(rzx,rzy);
}
示例15: RemoveFromPendingDelete
void CWebserverAppTraits::RemoveFromPendingDelete(wxObject *object)
{
wxMutexLocker lock(m_lock);
for(std::list<wxObject *>::iterator i = m_sched_delete.begin();
i != m_sched_delete.end(); i++) {
if (*i == object) {
m_sched_delete.erase(i);
return;
}
}
}