AbstractCollection | +--org.apache.commons.collections.buffer.BoundedFifoBufferAll Implemented Interfaces:
Constructs a new BoundedFifoBuffer big enough to hold 32 elements. |
BoundedFifoBuffer(int size) Constructs a new BoundedFifoBuffer big enough to hold the specified number of elements. |
BoundedFifoBuffer(Collection coll) Constructs a new BoundedFifoBuffer big enough to hold all of the elements in the specified collection. |
boolean | add(Object element) Adds the given element to this buffer. |
void | clear() Clears this buffer. |
Object | get() Returns the least recently inserted element in this buffer. |
boolean | isEmpty() Returns true if this buffer is empty; false otherwise. |
boolean | isFull() Returns true if this collection is full and no new elements can be added. |
Iterator | iterator() Returns an iterator over this buffer's elements. |
int | maxSize() Gets the maximum size of the collection (the bound). |
Object | remove() Removes the least recently inserted element from this buffer. |
int | size() Returns the number of elements stored in the buffer. |
public BoundedFifoBuffer()
BoundedFifoBuffer
big enough to hold
32 elements.
public BoundedFifoBuffer(Collection coll)
BoundedFifoBuffer
big enough to hold all
of the elements in the specified collection. That collection's
elements will also be added to the buffer.
- if the collection is nullpublic BoundedFifoBuffer(int size)
BoundedFifoBuffer
big enough to hold
the specified number of elements.
- if the size is less than 1public boolean add(Object element)
- if the given element is nullBufferOverflowException
- if this buffer is fullpublic void clear()
public Object get()
BufferUnderflowException
- if the buffer is emptypublic boolean isEmpty()
public boolean isFull()
public Iterator iterator()
public int maxSize()
public Object remove()
BufferUnderflowException
- if the buffer is emptypublic int size()
BoundedFifoBuffer
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 yourBoundedFifoBuffer
: This buffer prevents null objects from being added.