public class LRUBuffer<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 |
---|
LRUBuffer()
Default constructor.
|
LRUBuffer(java.lang.Class<?> genericTypeParameter)
Constructor for initializing with the generic type parameter
|
LRUBuffer(int bufferSize)
Initializes the buffer with a buffer size.
|
LRUBuffer(int bufferSize,
java.lang.Class<?> genericTypeParameter)
Constructor initializes with a buffer size and a generic type parameter.
|
LRUBuffer(java.lang.Iterable<? extends T> values)
Constructor initializes from another collection
|
LRUBuffer(java.lang.Iterable<? extends T> values,
java.lang.Class<?> genericTypeParameter)
Constructor initializes from another collection and a generic type parameter
|
LRUBuffer(ReifiedIterable<T> values)
Constructor initializes from another reified collection
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Empties the buffer.
|
boolean |
contains(T obj)
Returns true if an object is contained in the buffer.
|
T |
get()
Deprecated.
Use get(int) instead.
|
T |
get(int index)
Retrieves the object with specified index from the list.
|
java.lang.Class<?> |
getGenericTypeParameter()
Returns the class generic type parameters.
|
int |
getMaxSize()
Returns the maximum size.
|
boolean |
isEmpty()
Returns true if the buffer is empty.
|
boolean |
isFull()
Returns true if the buffer is full.
|
java.util.Iterator<T> |
iterator()
Returns an iterator over the backing list.
|
boolean |
put(T obj)
Puts an object in the buffer.
|
int |
size()
Returns the size of the Buffer.
|
T[] |
toArray()
Returns all elements in an array copy.
|
ReifiedList<T> |
toList()
Puts all elements in a list copy and returns them.
|
public static final int DEFAULT_SIZE
public LRUBuffer()
SuperTypeTokenException
- When called without using anonymous class semantics.public LRUBuffer(java.lang.Class<?> genericTypeParameter)
java.lang.NullPointerException
- When the generic type parameter is null.public LRUBuffer(int bufferSize)
java.lang.IllegalArgumentException
- When the buffer size is non positive.SuperTypeTokenException
- When called without using anonymous class semantics.public LRUBuffer(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 LRUBuffer(ReifiedIterable<T> values)
java.lang.NullPointerException
- When the argument is null.java.lang.IllegalArgumentException
- When the values is an empty iterable.public LRUBuffer(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 LRUBuffer(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 int getMaxSize()
getMaxSize
in interface IBuffer<T>
public boolean isEmpty()
public boolean isFull()
@Deprecated public T get()
public T get(int index)
java.lang.IndexOutOfBoundsException
- When the index provided is a negative number or beyond the buffer size.public java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
public java.lang.Class<?> getGenericTypeParameter()
getGenericTypeParameter
in interface ReifiedIterable<T>
public boolean put(T obj)
public int size()
public T[] toArray()
public ReifiedList<T> toList()