Possible Duplicate:
Size-limited queue that holds last N elements in Java
Java - Ring Buffer
I am interested in a bounded above queue, that whenever faced with object insertion, would remove the oldest object first, if the insertion would result in 'overflowing'. I want the addition to be O(1) and the memory usage as little as possible. I was thinking about either overriding add method on LinkedList, but ideally I would implement a circular, array based list, with catching front/back pointer. Whenever the addition is made over capacity, front pointer advances, and then the back one. Is there an implementation similar to this?