Changeset 7412 for code/trunk/src
- Timestamp:
- Sep 11, 2010, 4:16:10 PM (14 years ago)
- Location:
- code/trunk/src/modules/notifications
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/notifications/NotificationQueue.cc
r7410 r7412 153 153 while(it != this->ordering_.upper_bound(&this->timeLimit_)) 154 154 { 155 NotificationContainer* temp = *it;155 std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator temp = it; 156 156 it++; 157 157 this->remove(temp); // Remove the Notifications that have expired. … … 238 238 { 239 239 NotificationContainer* container = this->notifications_.back(); 240 this->ordering_.erase(container); 240 // Get all the NotificationContainers that were sent the same time the NotificationContainer we want to pop was sent. 241 std::pair<std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator, std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator> iterators = this->ordering_.equal_range(container); 242 // Iterate thourgh all suspects and remove the container as soon as we find it. 243 for(std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator it = iterators.first; it != iterators.second; it++) 244 { 245 if(container == *it) 246 { 247 this->ordering_.erase(it); 248 break; 249 } 250 } 241 251 this->notifications_.pop_back(); 242 252 … … 252 262 @brief 253 263 Removes the Notification that is stored in the input NotificationContainer. 254 @param container 255 The NotificationContainer with the Notificationto be removed.256 */ 257 void NotificationQueue::remove( NotificationContainer* container)258 { 259 std::vector<NotificationContainer*>::iterator it = std::find(this->notifications_.begin(), this->notifications_.end(), container);264 @param containerIterator 265 An iterator to the NotificationContainer to be removed. 266 */ 267 void NotificationQueue::remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator) 268 { 269 std::vector<NotificationContainer*>::iterator it = std::find(this->notifications_.begin(), this->notifications_.end(), *containerIterator); 260 270 // Get the index at which the Notification is. 261 271 std::vector<NotificationContainer*>::difference_type index = it - this->notifications_.begin (); 262 this->ordering_.erase(container );272 this->ordering_.erase(containerIterator); 263 273 this->notifications_.erase(it); 264 274 265 275 this->size_--; 266 276 267 delete container;277 delete *containerIterator; 268 278 269 279 // Removes the Notification from the GUI. -
code/trunk/src/modules/notifications/NotificationQueue.h
r7410 r7412 158 158 void push(Notification* notification, const std::time_t & time); //!< Adds (pushes) a Notification to the NotificationQueue. 159 159 void pop(void); //!< Removes (pops) the least recently added Notification form the NotificationQueue. 160 void remove( NotificationContainer* container); //!< Removes the Notification that is stored in the input NotificationContainer.160 void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); //!< Removes the Notification that is stored in the input NotificationContainer. 161 161 162 162 void clear(void); //!< Clears the NotificationQueue by removing all NotificationContainers.
Note: See TracChangeset
for help on using the changeset viewer.