CircularFifoBuffer is a first in first out buffer with a fixed size that replaces its oldest element if full.
The removal order of a CircularFifoBuffer
is based on the insertion order; elements are removed in the same order in which they were added. The iteration order is the same as the removal order.
The {@link #add(Object)}, {@link #remove()} and {@link #get()} operationsall perform in constant time. All other operations perform in linear time or worse.
Note that this implementation is not synchronized. The following can be used to provide synchronized access to your CircularFifoBuffer
:
Buffer fifo = BufferUtils.synchronizedBuffer(new CircularFifoBuffer());
This buffer prevents null objects from being added.
This class is Serializable from Commons Collections 3.1.
@since Commons Collections 3.0
@version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
@author Stefano Fornari
@author Stephen Colebourne