I am looking for a similar library as ArrayBlockingQueue. Just that, I don’t need the thread safe feature (For better performance purpose) offered in it, as it is using ReentrantLock in the offer(E e) method.
What I would like is
- A FIFO queue.
- Has an initial capacity, where pushing new element in will fail if the queue is full.
- Thread safety is not a requirement.
I don’t find ArrayQueue in Java standard library. Or, am I missing any classes?
There is a BoundedFiFoBuffer in the Common.Collections with the following properties:
The BoundedFifoBuffer is a very efficient implementation of Buffer that is of a fixed size.
The removal order of a BoundedFifoBuffer is based on the insertion order; elements are removed in the same order in which they were added.
The iteration order is the same as the removal order.
Note that this implementation is not synchronized.
BufferOverflowException is thrown on attempt to add elements to the full buffer.