Hi, I have requirement like this. For a function, i get input as a stream of numbers. I mean, function keeps on getting called with single number in each call. I am using queue for storing stream of numbers. I need to process a collected set of numbers only when some condition is satisfied. If condition is not satisfied i need to throw all the elements in the queue and then start storing new numbers in that. For emptying the queue, i couldn't find clear() method. So i am looping like below.
while(!q.empty())
q.pop();
I got efficient algorithm for clearing queue at
http://stackoverflow.com/questions/709146/how-do-i-clear-the-stdqueue-efficiently
My question is: Why queue doesn't support clear() function ?
When deque and vector are supporting clear() method, what is the technical difficulty in supporting it for queue ?
Or is my above usecase very rare and hence not supported ? Thank you.