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


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

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


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

示例1: removeListener

void EventManager::removeListener(GameObject *listener)
{
    do
    {
        if (mListenerMap.empty())
            break;
        
        ListenerMap::iterator mapIter = mListenerMap.begin();
        for (; mapIter != mListenerMap.end(); ++mapIter)
        {
            ListenerList *list = mapIter->second;
            if (list == NULL)
                continue;
            
            ListenerList::iterator listIter = list->begin();
            for (; listIter != list->end(); ++listIter)
            {
                if (*listIter == listener)
                {
                    list->erase(listIter);
                    break;
                }
            }
        }
        
    } while (0);
}
开发者ID:master-g,项目名称:hourglass,代码行数:27,代码来源:HGEventManager.cpp

示例2: cleanupUnusedListeners

void Environment::cleanupUnusedListeners(ListenerList& list)
{
  for(ListenerList::iterator giter = list.begin(); giter != list.end();){
    if((*giter)->isActive() == false){
      giter = list.erase(giter);
    } else ++giter;
  }
}
开发者ID:OMARTINEZ210,项目名称:server,代码行数:8,代码来源:script_environment.cpp

示例3: lock

// ============================================================================
void IncidentSvc::removeListener
( IIncidentListener* lis  ,
  const std::string& type )
{

  boost::recursive_mutex::scoped_lock lock(m_listenerMapMutex);

  if( type == "") {
    // remove Listener from all the lists
    ListenerMap::iterator itmap;
    for ( itmap = m_listenerMap.begin(); itmap != m_listenerMap.end();)
    {
      // since the current entry may be eventually deleted
      // we need to keep a memory of the next index before
      // calling recursively this method
      ListenerMap::iterator itmap_old = itmap;
      itmap++;
      removeListener( lis, (*itmap_old).first );
    }
  }
  else {
    ListenerMap::iterator itmap = m_listenerMap.find( type );

    if( itmap == m_listenerMap.end() ) {
      // if not found the incident type then return
      return;
    }
    else {
      ListenerList* llist = (*itmap).second;
      ListenerList::iterator itlist;
      bool justScheduleForRemoval = ( 0!= m_currentIncidentType )
                                    && (type == *m_currentIncidentType);
      // loop over all the entries in the Listener list
      // to remove all of them than matches
      // the listener address. Remember the next index
      // before erasing the current one
      for( itlist = llist->begin(); itlist != llist->end(); ) {
        if( (*itlist).iListener == lis || lis == 0) {
          if (justScheduleForRemoval) {
            (itlist++)->singleShot = true; // remove it as soon as it is safe
          }
          else {
            DEBMSG << "Removing [" << type << "] listener '"
                   << getListenerName(lis) << "'" << endmsg;
            itlist = llist->erase(itlist); // remove from the list now
          }
        }
        else {
          itlist++;
        }
      }
      if( llist->size() == 0) {
        delete llist;
        m_listenerMap.erase(itmap);
      }
    }
  }
}
开发者ID:l1calo,项目名称:gaudi,代码行数:59,代码来源:IncidentSvc.cpp


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