public class IntBuffer
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DROP_OLDEST_ON_FULL_POLICY
Drop oldest element when buffer is full and an element is added.
|
static int |
SKIP_DATA_ON_FULL_POLICY
When buffer is full, no element can be added.
|
Constructor and Description |
---|
IntBuffer(Monitor lock,
int size,
int policy)
Constructs an
IntBuffer initialized with a buffer of size elements. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(int i)
Add an element in this buffer.
|
int |
available()
Returns the number of integers that are stored in this buffer.
This method may be used before calling remove() to know if buffer is empty or not. |
int |
remove()
Remove the oldest element from this buffer and returns it.
This method is not blocking. |
public static final int DROP_OLDEST_ON_FULL_POLICY
public static final int SKIP_DATA_ON_FULL_POLICY
public IntBuffer(Monitor lock, int size, int policy)
IntBuffer
initialized with a buffer of size
elements.lock
- monitor used to synchronize accesses to the buffer.size
- maximum number of integer that can be stored in the buffer.policy
- DROP_OLDEST_ON_FULL_POLICY
or SKIP_DATA_ON_FULL_POLICY
public boolean add(int i)
i
- the integer to add in the buffer.public int remove()
public int available()
remove()
to know if buffer is empty or not.