public class CircularBuffer
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int |
allocBufferSize |
protected java.lang.Object[] |
bufferObjsArray |
protected int |
bufferPosition |
protected long |
totalItemsCounter |
Constructor and Description |
---|
CircularBuffer(int bufferSize)
Creates a circular buffer.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.Object obj)
Adds the given item to the buffer.
|
boolean |
contains(java.lang.Object obj)
Determines whether or not an equivalent item is contained in the
buffer.
|
java.lang.Object[] |
getBufferItems()
Returns an array containing the items in the buffer in the order
in which they were entered.
|
java.lang.String |
getBufferItemsAsString(java.lang.String sepStr)
Returns a string containing items in the buffer in the order
in which they were entered.
|
java.lang.String[] |
getStrBufferItems()
Returns an array containing string items in the buffer in the order
in which they were entered.
|
long |
getTotalItemsCount()
Returns a count of the total number of items that have ever been
entered into the buffer.
|
void |
setBufferSize(int bufferSize)
Sets the buffer size of the circular buffer.
|
protected java.lang.Object[] bufferObjsArray
protected int allocBufferSize
protected int bufferPosition
protected long totalItemsCounter
public CircularBuffer(int bufferSize)
bufferSize
- size of circular buffer.public final void setBufferSize(int bufferSize)
bufferSize
- size of circular buffer.public void add(java.lang.Object obj)
obj
- item to be added.public java.lang.Object[] getBufferItems()
public java.lang.String[] getStrBufferItems()
public java.lang.String getBufferItemsAsString(java.lang.String sepStr)
sepStr
- separator to be placed between each item.public long getTotalItemsCount()
public boolean contains(java.lang.Object obj)
obj
- item to check for.