Well, since generally, people are concerned about the ones that get dequeued, it's doubtful you're going to find a pre-written class to do what you want. However, creating your own should be that much trouble.
Inherit MyQueue for Queue:
public class MyQueue<T> : Queue<T>
or my may even want to go:
public class TennisBallQueue : Queue<TennisBall>
Then just override the Enqueue method to do the size check:
public new void Enqueue(TennisBall tb) { if (this.Count == MAX_TENNIS_BALLS) this.Dequeue();
base.Enqueue(tennisBall); }
(Unfortuantely the Enqueue is not virtual in the generic Queue<> class)
|