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 thisQueuetype.
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Queue<E>
Simple Ring Queue implementation that has an enforced max size value.
-
Constructor Summary
ConstructorsConstructorDescriptionRingQueue(int queueSize) Creates a newRingQueueinstance with the given fixed Queue size.RingQueue(Collection<E> collection) Creates a newRingQueueinstance with a size that matches the size of the givenCollectionand filled with the values from thatCollection. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddAll(Collection<? extends E> c) voidclear()booleanbooleanisEmpty()iterator()booleanpeek()poll()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.booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()Methods inherited from class java.util.AbstractQueue
add, element, removeMethods inherited from class java.util.AbstractCollection
containsAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
containsAll, equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray, toArray, toArray
-
Constructor Details
-
RingQueue
public RingQueue(int queueSize) Creates a newRingQueueinstance with the given fixed Queue size.- Parameters:
queueSize- The size to use for the ring queue.
-
RingQueue
Creates a newRingQueueinstance with a size that matches the size of the givenCollectionand filled with the values from thatCollection.- Parameters:
collection- theCollectionwhose values populates thisRingQueueinstance.
-
-
Method Details
-
offer
-
poll
-
poll
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. -
peek
-
addAll
- Specified by:
addAllin interfaceCollection<E>- Overrides:
addAllin classAbstractQueue<E>
-
remove
- Specified by:
removein interfaceCollection<E>- Overrides:
removein classAbstractCollection<E>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E>- Overrides:
removeAllin classAbstractCollection<E>
-
retainAll
- Specified by:
retainAllin interfaceCollection<E>- Overrides:
retainAllin classAbstractCollection<E>
-
iterator
- Specified by:
iteratorin interfaceCollection<E>- Specified by:
iteratorin interfaceIterable<E>- Specified by:
iteratorin classAbstractCollection<E>
-
size
public int size()- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein classAbstractCollection<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E>- Overrides:
isEmptyin classAbstractCollection<E>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E>- Overrides:
clearin classAbstractQueue<E>
-
contains
- Specified by:
containsin interfaceCollection<E>- Overrides:
containsin classAbstractCollection<E>
-