Package com.rabbitmq.client.impl
Class SetQueue<T>
- java.lang.Object
-
- com.rabbitmq.client.impl.SetQueue<T>
-
- Type Parameters:
T
- type of elements in the queue
public class SetQueue<T> extends Object
A generic queue-like implementation (supporting operations
Elements must not beaddIfNotPresent
,poll
,contains
, andisEmpty
) which restricts a queue element to appear at most once. If the element is already presentaddIfNotPresent(T)
returnsfalse
.null
.Concurrent Semantics
This implementation is not thread-safe.
-
-
Constructor Summary
Constructors Constructor Description SetQueue()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addIfNotPresent(T item)
Add an element to the back of the queue and returntrue
, or else returnfalse
.void
clear()
Remove all items from the queue.boolean
contains(T item)
boolean
isEmpty()
T
poll()
Remove the head of the queue and return it.boolean
remove(T item)
Remove item from queue, if present.
-
-
-
Method Detail
-
addIfNotPresent
public boolean addIfNotPresent(T item)
Add an element to the back of the queue and returntrue
, or else returnfalse
.- Parameters:
item
- to add- Returns:
true
if the element was added,false
if it is already present.
-
poll
public T poll()
Remove the head of the queue and return it.- Returns:
- head element of the queue, or
null
if the queue is empty.
-
contains
public boolean contains(T item)
- Parameters:
item
- to look for in queue- Returns:
true
if and only if item is in the queue.
-
isEmpty
public boolean isEmpty()
- Returns:
true
if and only if the queue is empty.
-
remove
public boolean remove(T item)
Remove item from queue, if present.- Parameters:
item
- to remove- Returns:
true
if and only if item was initially present and was removed.
-
clear
public void clear()
Remove all items from the queue.
-
-