|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.common.collect.Queues
@Beta public final class Queues
Static utility methods pertaining to Queue
instances. Also see this class's counterparts
Lists
, Sets
, and Maps
.
Method Summary | ||
---|---|---|
static
|
drain(BlockingQueue<E> q,
Collection<? super E> buffer,
int numElements,
long timeout,
TimeUnit unit)
Drains the queue as BlockingQueue.drainTo(Collection, int) , but if the requested
numElements elements are not available, it will wait for them up to the specified
timeout. |
|
static
|
drainUninterruptibly(BlockingQueue<E> q,
Collection<? super E> buffer,
int numElements,
long timeout,
TimeUnit unit)
Drains the queue as drain(BlockingQueue, Collection, int, long, TimeUnit), but with a different behavior in case it is interrupted while waiting. |
|
static
|
newArrayBlockingQueue(int capacity)
Creates an empty ArrayBlockingQueue instance. |
|
static
|
newConcurrentLinkedQueue()
Creates an empty ConcurrentLinkedQueue instance. |
|
static
|
newConcurrentLinkedQueue(Iterable<? extends E> elements)
Creates an ConcurrentLinkedQueue instance containing the given elements. |
|
static
|
newLinkedBlockingQueue()
Creates an empty LinkedBlockingQueue instance. |
|
static
|
newLinkedBlockingQueue(int capacity)
Creates a LinkedBlockingQueue with the given (fixed) capacity. |
|
static
|
newLinkedBlockingQueue(Iterable<? extends E> elements)
Creates an LinkedBlockingQueue instance containing the given elements. |
|
static
|
newPriorityBlockingQueue()
Creates an empty PriorityBlockingQueue instance. |
|
static
|
newPriorityBlockingQueue(Iterable<? extends E> elements)
Creates an PriorityBlockingQueue instance containing the given elements. |
|
static
|
newPriorityQueue()
Creates an empty PriorityQueue instance. |
|
static
|
newPriorityQueue(Iterable<? extends E> elements)
Creates an PriorityQueue instance containing the given elements. |
|
static
|
newSynchronousQueue()
Creates an empty SynchronousQueue instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <E> ArrayBlockingQueue<E> newArrayBlockingQueue(int capacity)
ArrayBlockingQueue
instance.
ArrayBlockingQueue
public static <E> ConcurrentLinkedQueue<E> newConcurrentLinkedQueue()
ConcurrentLinkedQueue
instance.
ConcurrentLinkedQueue
public static <E> ConcurrentLinkedQueue<E> newConcurrentLinkedQueue(Iterable<? extends E> elements)
ConcurrentLinkedQueue
instance containing the given elements.
elements
- the elements that the queue should contain, in order
ConcurrentLinkedQueue
containing those elementspublic static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue()
LinkedBlockingQueue
instance.
LinkedBlockingQueue
public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue(int capacity)
LinkedBlockingQueue
with the given (fixed) capacity.
capacity
- the capacity of this queue
LinkedBlockingQueue
IllegalArgumentException
- if capacity
is less than 1public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue(Iterable<? extends E> elements)
LinkedBlockingQueue
instance containing the given elements.
elements
- the elements that the queue should contain, in order
LinkedBlockingQueue
containing those elementspublic static <E> PriorityBlockingQueue<E> newPriorityBlockingQueue()
PriorityBlockingQueue
instance.
PriorityBlockingQueue
public static <E> PriorityBlockingQueue<E> newPriorityBlockingQueue(Iterable<? extends E> elements)
PriorityBlockingQueue
instance containing the given elements.
elements
- the elements that the queue should contain, in order
PriorityBlockingQueue
containing those elementspublic static <E> PriorityQueue<E> newPriorityQueue()
PriorityQueue
instance.
PriorityQueue
public static <E> PriorityQueue<E> newPriorityQueue(Iterable<? extends E> elements)
PriorityQueue
instance containing the given elements.
elements
- the elements that the queue should contain, in order
PriorityQueue
containing those elementspublic static <E> SynchronousQueue<E> newSynchronousQueue()
SynchronousQueue
instance.
SynchronousQueue
public static <E> int drain(BlockingQueue<E> q, Collection<? super E> buffer, int numElements, long timeout, TimeUnit unit) throws InterruptedException
BlockingQueue.drainTo(Collection, int)
, but if the requested
numElements
elements are not available, it will wait for them up to the specified
timeout.
q
- the blocking queue to be drainedbuffer
- where to add the transferred elementsnumElements
- the number of elements to be waited fortimeout
- how long to wait before giving up, in units of unit
unit
- a TimeUnit
determining how to interpret the timeout parameter
InterruptedException
- if interrupted while waitingpublic static <E> int drainUninterruptibly(BlockingQueue<E> q, Collection<? super E> buffer, int numElements, long timeout, TimeUnit unit)
InterruptedException
is thrown).
q
- the blocking queue to be drainedbuffer
- where to add the transferred elementsnumElements
- the number of elements to be waited fortimeout
- how long to wait before giving up, in units of unit
unit
- a TimeUnit
determining how to interpret the timeout parameter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |