Package org.epics.pvaccess.util
Class GrowingCircularBuffer<T>
- java.lang.Object
-
- org.epics.pvaccess.util.GrowingCircularBuffer<T>
-
- Type Parameters:
T- buffer element type.
public final class GrowingCircularBuffer<T> extends Object
Implementaton of circular FIFO unbouded buffer. Instance is not a bit synchronized.- Author:
- Matej Sekoranja
-
-
Constructor Summary
Constructors Constructor Description GrowingCircularBuffer(int capacity)Create a BoundedBuffer with the given capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcapacity()Get current buffer capacity.Textract()Extract the oldest element from the buffer.booleaninsert(T x)Insert a new element in to the buffer.intsize()Get number of elements in the buffer.
-
-
-
Constructor Detail
-
GrowingCircularBuffer
public GrowingCircularBuffer(int capacity) throws IllegalArgumentExceptionCreate a BoundedBuffer with the given capacity.- Parameters:
capacity- buffer capacity.- Throws:
IllegalArgumentException- if capacity less or equal to zero
-
-
Method Detail
-
size
public int size()
Get number of elements in the buffer.- Returns:
- number of elements in the buffer.
-
capacity
public int capacity()
Get current buffer capacity.- Returns:
- buffer current capacity.
-
insert
public final boolean insert(T x)
Insert a new element in to the buffer. If buffer full, oldest element will be overriden.- Parameters:
x- element to insert.- Returns:
trueif first element.
-
extract
public final T extract()
Extract the oldest element from the buffer.- Returns:
- the oldest element from the buffer.
-
-