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