java.lang.Object | |||
↳ | java.util.AbstractCollection<E> | ||
↳ | org.apache.commons.collections.buffer.BoundedFifoBuffer | ||
↳ | org.apache.commons.collections.buffer.CircularFifoBuffer |
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 add(Object)
, remove()
and get()
operations
all 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.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor that creates a buffer with the default size of 32.
| |||||||||||
Constructor that creates a buffer with the specified size.
| |||||||||||
Constructor that creates a buffer from the specified collection.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
If the buffer is full, the least recently added element is discarded so
that a new element can be inserted.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.commons.collections.buffer.BoundedFifoBuffer
| |||||||||||
From class
java.util.AbstractCollection
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Iterable
| |||||||||||
From interface
java.util.Collection
| |||||||||||
From interface
org.apache.commons.collections.BoundedCollection
| |||||||||||
From interface
org.apache.commons.collections.Buffer
|
Constructor that creates a buffer with the default size of 32.
Constructor that creates a buffer with the specified size.
size | the size of the buffer (cannot be changed) |
---|
IllegalArgumentException | if the size is less than 1 |
---|
Constructor that creates a buffer from the specified collection. The collection size also sets the buffer size
coll | the collection to copy into the buffer, may not be null |
---|
NullPointerException | if the collection is null |
---|
If the buffer is full, the least recently added element is discarded so that a new element can be inserted.
element | the element to add |
---|