From e55997e6147758ec58d2c1031293a375c7284dc1 Mon Sep 17 00:00:00 2001 From: adrian Date: Tue, 25 Sep 2012 12:39:06 +0000 Subject: [PATCH] Removed remove(iterator) (no longer needed), m_remove() simplified. git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1688 8c4709b5-6ec9-48aa-a5cd-a96041d1645a --- src/core/sal/ListenerManager.cc | 15 +++------------ src/core/sal/ListenerManager.hpp | 11 +---------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/core/sal/ListenerManager.cc b/src/core/sal/ListenerManager.cc index 7bc8a7f2..5ef23274 100644 --- a/src/core/sal/ListenerManager.cc +++ b/src/core/sal/ListenerManager.cc @@ -113,18 +113,9 @@ void ListenerManager::m_remove(index_t idx) } } -ListenerManager::iterator ListenerManager::m_remove(iterator it, bool skip_deletelist) +ListenerManager::iterator ListenerManager::m_remove(iterator it) { - if (!skip_deletelist) { - // If skip_deletelist = true, m_remove was called from makeActive. Accordingly, we - // are not going to delete an listener, instead we are "moving" a listener object (= *it) - // from the buffer list to the fire-list. Therefore we only need to call the simulator's - // listener handler (onDeletion), if m_remove is called with the primary intention - // to *delete* (not "move") a listener. - (*it)->onDeletion(); - m_DeleteList.push_back(*it); - } - + (*it)->onDeletion(); // This has O(1) time complexity due to a underlying std::vector (-> random access iterator) index_t dist = std::distance(begin(), it); assert((*it)->getPerformanceBuffer() == NULL && @@ -211,7 +202,7 @@ ListenerManager::iterator ListenerManager::makeActive(iterator it) li->resetCounter(); // Note: This is the one and only situation in which remove() should NOT // store the removed item in the delete-list. - iterator it_next = m_remove(it, true); // remove listener from buffer-list + iterator it_next = m_remove(it); // remove listener from buffer-list m_FireList.push_back(li); return it_next; } diff --git a/src/core/sal/ListenerManager.hpp b/src/core/sal/ListenerManager.hpp index a7f2768b..307ccfb3 100644 --- a/src/core/sal/ListenerManager.hpp +++ b/src/core/sal/ListenerManager.hpp @@ -90,23 +90,14 @@ public: * buffer-list implementation. */ void remove(BaseListener* li); - /** - * Behaves like remove(BaseListener*) and additionally updates the provided - * iterator. - * @param it the iterator pointing to the Listener object to be removed - * @return the updated iterator which will point to the next element - */ - iterator remove(iterator it) { return m_remove(it, false); } private: /** * Internal implementation of remove(iterator it) that allows * to skip the delete-list. * @param it the iterator pointing to the Listener object to be removed - * @param skip_deletelist \c true to skip the deletion of the Listener object - * or \false to behave like \c remove(iterator) * @return the updated iterator which will point to the next element */ - iterator m_remove(iterator it, bool skip_deletelist); + iterator m_remove(iterator it); /** * Updates the buffer-list by "removing" the element located at index \c idx. * This is done by replacing the element with the last element of the vector.