E
- Elementpublic class RingBuffer<E>
extends java.lang.Object
clear()
. To fetch all elements from the collection
you should call getCollection()
, where the buffer will completely
remove all elements and you can start to refill the buffer from scratch. The
iterator()
internally calls getCollection()
and therefore
also removes all elements.Modifier and Type | Class and Description |
---|---|
static class |
RingBuffer.EmptyQueueException
Runtime exception of an empty queue.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_ELEMENTS |
Constructor and Description |
---|
RingBuffer(int maxElements)
Creates a new instance of a ring buffer with a specified maximum length
of elements, where this must be greater then
DEFAULT_ELEMENTS . |
RingBuffer(RingBuffer<E> toClone)
Creates a new instance of a ring buffer by deeply copying the elements from
the cloneable buffer.
|
Modifier and Type | Method and Description |
---|---|
void |
add(E e)
Adds an element to the queue.
|
void |
clear()
Clears the buffer and removes all elements.
|
E |
get()
Returns an element (object) from queue.
|
java.util.Collection<E> |
getCollection()
Returns all elements from the queue and clears it.
|
boolean |
isEmpty()
Returns
true if queue is empty, otherwise false |
java.util.Iterator<E> |
iterator()
Iterates the queue.
|
E |
peek()
Peeks an element in the queue.
|
E |
remove()
Removes the newest element from the queue.
|
int |
size()
Returns queue size.
|
public static final int DEFAULT_ELEMENTS
public RingBuffer(int maxElements)
DEFAULT_ELEMENTS
.maxElements
- Maximum number of elements.public RingBuffer(RingBuffer<E> toClone)
toClone
- Buffer to be deeply copied to the create instance.public void clear()
public void add(E e)
e
- Element.public E get()
null
if queue is emptypublic java.util.Collection<E> getCollection()
public java.util.Iterator<E> iterator()
getCollection()
.getCollection()
public E remove()
null
if the buffer is empty.public E peek()
null
if queue is emptypublic boolean isEmpty()
true
if queue is empty, otherwise false
public int size()
14-September-2016 18:23 Deutsches Elektronen-Synchrotron DESY in der Helmholtz-Gemeinschaft