public class CircularBuffer<E> extends Object
Constructor and Description |
---|
CircularBuffer()
Create a circular buffer with the maximum allowed size
|
CircularBuffer(int size)
Create a circular buffer with the given size
|
Modifier and Type | Method and Description |
---|---|
void |
append(E element)
Append elements while preserving the circular nature of the buffer.
|
void |
clear()
Clear the circular buffer and reset the indices.
|
List<E> |
get(int amount)
Retrieve the given amount of elements from the circular buffer.
|
Object[] |
getObjects(int amount)
This method is added for backward compatibility.
|
int |
getSize()
Return the capacity of the circular buffer.
|
public CircularBuffer(int size)
size
- - fixed size of the bufferpublic CircularBuffer()
public void append(E element)
element
- - element to be appendedpublic List<E> get(int amount)
amount
- - no of elements to returnpublic Object[] getObjects(int amount)
amount
- - amount of elements to return from the bufferpublic void clear()
public int getSize()
Copyright © 2016 WSO2 Inc. All rights reserved.