ConcurrentRing
A ring buffer that supports concurrent access.
| Methods |
| void |
add(K obj)
Add an element at the end.
|
| void |
add(K obj)
Add an element at the end.
Parameters:
obj - the element
|
| int |
getIndex(int pos)
Get the index in the array of the given position.
|
| int |
getIndex(int pos)
Get the index in the array of the given position.
Parameters:
pos - the position
Returns:
the index
|
| Iterator |
iterator()
Get an iterator over all entries.
|
| Iterator |
iterator()
Get an iterator over all entries.
Returns:
the iterator
|
| K |
peekFirst()
Get the first element, or null if none.
|
| K |
peekFirst()
Get the first element, or null if none.
Returns:
the first element
|
| K |
peekLast()
Get the last element, or null if none.
|
| K |
peekLast()
Get the last element, or null if none.
Returns:
the last element
|
| boolean |
removeFirst(K obj)
Remove the first element, if it matches.
|
| boolean |
removeFirst(K obj)
Remove the first element, if it matches.
Parameters:
obj - the element to remove
Returns:
true if the element matched and was removed
|
| boolean |
removeLast(K obj)
Remove the last element, if it matches.
|
| boolean |
removeLast(K obj)
Remove the last element, if it matches.
Parameters:
obj - the element to remove
Returns:
true if the element matched and was removed
|
buffer
The ring buffer.
readPos
The read position.
writePos
The write position.
|