本文整理汇总了C++中EventListenerVector::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ EventListenerVector::remove方法的具体用法?C++ EventListenerVector::remove怎么用?C++ EventListenerVector::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventListenerVector
的用法示例。
在下文中一共展示了EventListenerVector::remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeListenerFromVector
static bool removeListenerFromVector(EventListenerVector& listeners, EventListener& listener, bool useCapture)
{
size_t indexOfRemovedListener = findListener(listeners, listener, useCapture);
if (UNLIKELY(indexOfRemovedListener == notFound))
return false;
listeners[indexOfRemovedListener]->markAsRemoved();
listeners.remove(indexOfRemovedListener);
return true;
}
示例2: removeEventListener
bool EventTarget::removeEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture)
{
EventTargetData* d = eventTargetData();
if (!d)
return false;
EventListenerMap::iterator result = d->eventListenerMap.find(eventType);
if (result == d->eventListenerMap.end())
return false;
EventListenerVector* entry = result->second;
RegisteredEventListener registeredListener(listener, useCapture);
size_t index = entry->find(registeredListener);
if (index == notFound)
return false;
entry->remove(index);
if (entry->isEmpty()) {
delete entry;
d->eventListenerMap.remove(result);
}
// Notify firing events planning to invoke the listener at 'index' that
// they have one less listener to invoke.
for (size_t i = 0; i < d->firingEventIterators.size(); ++i) {
if (eventType != d->firingEventIterators[i].eventType)
continue;
if (index >= d->firingEventIterators[i].end)
continue;
--d->firingEventIterators[i].end;
if (index <= d->firingEventIterators[i].iterator)
--d->firingEventIterators[i].iterator;
}
return true;
}