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:
Iterable<E>
,Collection<E>
,Queue<E>
Simple Ring Queue implementation that has an enforced max size value.
-
Constructor Summary
ConstructorDescriptionRingQueue
(int queueSize) Creates a newRingQueue
instance with the given fixed Queue size.RingQueue
(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
Modifier and TypeMethodDescriptionboolean
addAll
(Collection<? extends E> c) void
clear()
boolean
boolean
isEmpty()
iterator()
boolean
peek()
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
.boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) int
size()
Methods inherited from class java.util.AbstractQueue
add, element, remove
Methods inherited from class java.util.AbstractCollection
containsAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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 newRingQueue
instance with the given fixed Queue size.- Parameters:
queueSize
- The size to use for the ring queue.
-
RingQueue
Creates a newRingQueue
instance with a size that matches the size of the givenCollection
and filled with the values from thatCollection
.- Parameters:
collection
- theCollection
whose values populates thisRingQueue
instance.
-
-
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:
addAll
in interfaceCollection<E>
- Overrides:
addAll
in classAbstractQueue<E>
-
remove
- Specified by:
remove
in interfaceCollection<E>
- Overrides:
remove
in classAbstractCollection<E>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<E>
- Overrides:
removeAll
in classAbstractCollection<E>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<E>
- Overrides:
retainAll
in classAbstractCollection<E>
-
iterator
- Specified by:
iterator
in interfaceCollection<E>
- Specified by:
iterator
in interfaceIterable<E>
- Specified by:
iterator
in classAbstractCollection<E>
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in classAbstractCollection<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<E>
- Overrides:
isEmpty
in classAbstractCollection<E>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E>
- Overrides:
clear
in classAbstractQueue<E>
-
contains
- Specified by:
contains
in interfaceCollection<E>
- Overrides:
contains
in classAbstractCollection<E>
-