Is there a Queue type collection in .NET at allows elements to be pushed out of the queue when the capacity of the queue is reached?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’d suggest creating a new class, rather than subclassing queue, since the limited-length queue class should not be passable to code which might call the old enqueue method. There are a number of logical things that a queue might do if a push occurs when full:
It may be good to create an inheritable base class, and then create derived classes which implement particular behaviors. That way methods which care about the problem scenario could demand a class which promises handles it correctly. Note that the last scenario may seem strange, but there are times it’d be appropriate, e.g. an event handler putting data into a queue for some other task to process. If the queue is large enough that it shouldn’t ever overflow, but the reader task gets blocked, it may be be undesirable to have such blockage percolate back to the event sender.