Caller can chose whether to block until get / put is able to proceed or not.
Caller can chose whether to pass an empty array and clear references at get, or using a preset array for circular access of same objects.
Synchronization and hence thread safety details belong to the implementation.
| Modifier and Type | Method and Description |
|---|---|
| public int | |
| public void | clear()
Resets the read and write position according to an empty ring buffer
and set all ring buffer slots to |
| public void | dump(PrintStream stream, String prefix)
Debug functionality - Dumps the contents of the internal array. |
| public T | Returns: the oldest put element if available, otherwise null.Dequeues the oldest enqueued element if available, otherwise null. |
| public T | |
| public int | |
| public void | growEmptyBuffer(T[]
array of new full elements the empty buffer shall grow about. newElements)Grows an empty ring buffer, increasing it's capacity about the amount. |
| public void | growFullBuffer(int
the amount of elements the buffer shall grow about amount)Grows a full ring buffer, increasing it's capacity about the amount. |
| public boolean | |
| public boolean | |
| public T | Returns: null if empty, otherwise the element which would be read next.Peeks the next element at the read position w/o modifying pointer, nor blocking. |
| public T | Returns: null if empty, otherwise the element which would be read next.Peeks the next element at the read position w/o modifying pointer, but w/ blocking. |
| public boolean | |
| public void | |
| public boolean | putSame(boolean
if true, wait until a free slot becomes available via get. blocking)Enqueues the same element at it's write position, if not full. |
| public void | resetFull(T[]
Mandatory array w/ length copyFrom)capacity() to be copied into the internal array.Resets the read and write position according to a full ring buffer
and fill all slots w/ elements of array |
| public int | |
| public String | |
| public void |
| capacity | back to summary |
|---|---|
| public int capacity() Returns the net capacity of this ring buffer. | |
| clear | back to summary |
|---|---|
| public void clear() Resets the read and write position according to an empty ring buffer
and set all ring buffer slots to
| |
| dump | back to summary |
|---|---|
| public void dump(PrintStream stream, String prefix) Debug functionality - Dumps the contents of the internal array. | |
| get | back to summary |
|---|---|
| public T get() Dequeues the oldest enqueued element if available, otherwise null.
The returned ring buffer slot will be set to Method is non blocking and returns immediately;.
| |
| getBlocking | back to summary |
|---|---|
| public T getBlocking() throws InterruptedException Dequeues the oldest enqueued element.
The returned ring buffer slot will be set to Methods blocks until an element becomes available via put.
| |
| getFreeSlots | back to summary |
|---|---|
| public int getFreeSlots() Returns the number of free slots available to put. | |
| growEmptyBuffer | back to summary |
|---|---|
| public void growEmptyBuffer(T[] newElements) throws IllegalStateException, IllegalArgumentException Grows an empty ring buffer, increasing it's capacity about the amount.
Growing an empty ring buffer increases it's size about the amount, i.e. renders it not empty.
The new elements are inserted at the read position, able to be read out via
| |
| growFullBuffer | back to summary |
|---|---|
| public void growFullBuffer(int amount) throws IllegalStateException, IllegalArgumentException Grows a full ring buffer, increasing it's capacity about the amount.
Growing a full ring buffer leaves the size intact, i.e. renders it not full.
New
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Returns true if this ring buffer is empty, otherwise false. | |
| isFull | back to summary |
|---|---|
| public boolean isFull() Returns true if this ring buffer is full, otherwise false. | |
| peek | back to summary |
|---|---|
| public T peek() Peeks the next element at the read position w/o modifying pointer, nor blocking.
| |
| peekBlocking | back to summary |
|---|---|
| public T peekBlocking() throws InterruptedException Peeks the next element at the read position w/o modifying pointer, but w/ blocking.
| |
| put | back to summary |
|---|---|
| public boolean put(T e) Enqueues the given element. Returns true if successful, otherwise false in case buffer is full. Method is non blocking and returns immediately;. | |
| putBlocking | back to summary |
|---|---|
| public void putBlocking(T e) throws InterruptedException Enqueues the given element. Method blocks until a free slot becomes available via get. | |
| putSame | back to summary |
|---|---|
| public boolean putSame(boolean blocking) throws InterruptedException Enqueues the same element at it's write position, if not full. Returns true if successful, otherwise false in case buffer is full.
If
| |
| resetFull | back to summary |
|---|---|
| public void resetFull(T[] copyFrom) throws IllegalArgumentException Resets the read and write position according to a full ring buffer
and fill all slots w/ elements of array
Array's
| |
| size | back to summary |
|---|---|
| public int size() Returns the number of elements in this ring buffer. | |
| toString | back to summary |
|---|---|
| public String toString() Returns a short string representation incl. size/capacity and internal r/w index (impl. dependent).
| |
| waitForFreeSlots | back to summary |
|---|---|
| public void waitForFreeSlots(int count) throws InterruptedException Blocks until at least | |