public class CircularBuffer<T> extends java.lang.Object implements IBuffer<T>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SIZE
The default size of the buffer, if none is specified.
|
Constructor and Description |
---|
CircularBuffer()
Default constructor.
|
CircularBuffer(java.lang.Class<?> genericTypeParameter)
Constructor for initializing with the generic type parameter
|
CircularBuffer(int bufferSize)
Initializes the buffer with the buffer size.
|
CircularBuffer(int bufferSize,
java.lang.Class<?> genericTypeParameter)
Constructor initializes with the buffer size and a generic type parameter.
|
CircularBuffer(java.lang.Iterable<? extends T> values)
Constructor initializes from another collection
|
CircularBuffer(java.lang.Iterable<? extends T> values,
java.lang.Class<?> genericTypeParameter)
Constructor initializes from another collection and a generic type parameter
|
CircularBuffer(ReifiedIterable<T> values)
Constructor initializes from another reified collection
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Empties the buffer.
|
boolean |
contains(T obj)
Checks if an object is contained in the buffer.
|
T |
get()
Retrieves an object from the buffer if one is available.
|
java.lang.Class<?> |
getGenericTypeParameter()
Returns the class generic type parameters.
|
int |
getMaxSize()
Maximum size method.
|
boolean |
isEmpty()
Is empty method.
|
boolean |
isFull()
Is full method.
|
java.util.Iterator<T> |
iterator()
Returns an iterator over the buffer.
|
boolean |
put(T obj)
Puts an object in the buffer.
|
int |
size()
Returns the size of the Buffer.
|
T[] |
toArray()
Puts all elements in an array copy and returns them.
|
ReifiedList<T> |
toList()
Puts all elements in a list copy and returns them.
|
java.lang.String |
toString() |
public static final int DEFAULT_SIZE
public CircularBuffer()
SuperTypeTokenException
- When called without using anonymous class semantics.public CircularBuffer(java.lang.Class<?> genericTypeParameter)
java.lang.NullPointerException
- When the generic type parameter is null.public CircularBuffer(int bufferSize)
java.lang.IllegalArgumentException
- When the buffer size is non positive.SuperTypeTokenException
- When called without using anonymous class semantics.public CircularBuffer(int bufferSize, java.lang.Class<?> genericTypeParameter)
java.lang.IllegalArgumentException
- When the buffer size is non positive.java.lang.NullPointerException
- When the generic type parameter is null.public CircularBuffer(ReifiedIterable<T> values)
java.lang.NullPointerException
- When the argument is null.java.lang.IllegalArgumentException
- When the values is an empty iterable.public CircularBuffer(java.lang.Iterable<? extends T> values)
SuperTypeTokenException
- When called without using anonymous class semantics.java.lang.IllegalArgumentException
- When the values is an empty iterable.java.lang.NullPointerException
- When the argument is nullpublic CircularBuffer(java.lang.Iterable<? extends T> values, java.lang.Class<?> genericTypeParameter)
java.lang.NullPointerException
- When an argument is null.java.lang.IllegalArgumentException
- When the values is an empty iterable.public void clear()
public boolean contains(T obj)
public java.lang.Class<?> getGenericTypeParameter()
ReifiedIterable
getGenericTypeParameter
in interface ReifiedIterable<T>
public int getMaxSize()
getMaxSize
in interface IBuffer<T>
public boolean isEmpty()
public boolean isFull()
public T get()
public java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
public boolean put(T obj)
public int size()
public T[] toArray()
public ReifiedList<T> toList()
public java.lang.String toString()
toString
in class java.lang.Object