Class RingQueue<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<E>
-
- org.apache.qpid.protonj2.engine.util.RingQueue<E>
-
- Type Parameters:
E
- the element type that is stored in thisQueue
type.
- All Implemented Interfaces:
java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.Queue<E>
public class RingQueue<E> extends java.util.AbstractQueue<E>
Simple Ring Queue implementation that has an enforced max size value.
-
-
Constructor Summary
Constructors Constructor Description RingQueue(int queueSize)
Creates a newRingQueue
instance with the given fixed Queue size.RingQueue(java.util.Collection<E> collection)
Creates a newRingQueue
instance with a size that matches the size of the givenCollection
and filled with the values from thatCollection
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addAll(java.util.Collection<? extends E> c)
void
clear()
boolean
contains(java.lang.Object value)
boolean
isEmpty()
java.util.Iterator<E>
iterator()
boolean
offer(E e)
E
peek()
E
poll()
E
poll(java.util.function.Supplier<E> createOnEmpty)
Retrieves and removes the head of this ring queue, and if the queue is currently empty a new instance of the queue type is provided by invoking the givenSupplier
.boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
boolean
retainAll(java.util.Collection<?> c)
int
size()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Constructor Detail
-
RingQueue
public RingQueue(int queueSize)
Creates a newRingQueue
instance with the given fixed Queue size.- Parameters:
queueSize
- The size to use for the ring queue.
-
-
Method Detail
-
offer
public boolean offer(E e)
-
poll
public E poll()
-
poll
public E poll(java.util.function.Supplier<E> createOnEmpty)
Retrieves and removes the head of this ring queue, and if the queue is currently empty a new instance of the queue type is provided by invoking the givenSupplier
.- Parameters:
createOnEmpty
- aSupplier
which will return default values if theRingQueue
is empty.- Returns:
- the head element of this queue or a default instance created from the provided
Supplier
/
-
peek
public E peek()
-
addAll
public boolean addAll(java.util.Collection<? extends E> c)
-
remove
public boolean remove(java.lang.Object o)
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
iterator
public java.util.Iterator<E> iterator()
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
clear
public void clear()
-
-