![JAR search and dependency download from the Maven repository](/logo.png)
javadoc.com.google.common.collect.Queues.html Maven / Gradle / Ivy
The newest version!
Queues (Guava: Google Core Libraries for Java 11.0.1 API)
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
com.google.common.collect
Class Queues
java.lang.Object
com.google.common.collect.Queues
Static utility methods pertaining to Queue
instances. Also see this class's counterparts
Lists
, Sets
, and Maps
.
- Since:
- 11.0
- Author:
- Kurt Alfred Kluever
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 |
---|
newArrayBlockingQueue
public static <E> ArrayBlockingQueue<E> newArrayBlockingQueue(int capacity)
- Creates an empty
ArrayBlockingQueue
instance.- Returns:
- a new, empty
ArrayBlockingQueue
newConcurrentLinkedQueue
public static <E> ConcurrentLinkedQueue<E> newConcurrentLinkedQueue()
- Creates an empty
ConcurrentLinkedQueue
instance.- Returns:
- a new, empty
ConcurrentLinkedQueue
newConcurrentLinkedQueue
public static <E> ConcurrentLinkedQueue<E> newConcurrentLinkedQueue(Iterable<? extends E> elements)
- Creates an
ConcurrentLinkedQueue
instance containing the given elements.- Parameters:
elements
- the elements that the queue should contain, in order- Returns:
- a new
ConcurrentLinkedQueue
containing those elements
newLinkedBlockingQueue
public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue()
- Creates an empty
LinkedBlockingQueue
instance.- Returns:
- a new, empty
LinkedBlockingQueue
newLinkedBlockingQueue
public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue(int capacity)
- Creates a
LinkedBlockingQueue
with the given (fixed) capacity.- Parameters:
capacity
- the capacity of this queue- Returns:
- a new, empty
LinkedBlockingQueue
- Throws:
IllegalArgumentException
- ifcapacity
is less than 1
newLinkedBlockingQueue
public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue(Iterable<? extends E> elements)
- Creates an
LinkedBlockingQueue
instance containing the given elements.- Parameters:
elements
- the elements that the queue should contain, in order- Returns:
- a new
LinkedBlockingQueue
containing those elements
newPriorityBlockingQueue
public static <E> PriorityBlockingQueue<E> newPriorityBlockingQueue()
- Creates an empty
PriorityBlockingQueue
instance.- Returns:
- a new, empty
PriorityBlockingQueue
newPriorityBlockingQueue
public static <E> PriorityBlockingQueue<E> newPriorityBlockingQueue(Iterable<? extends E> elements)
- Creates an
PriorityBlockingQueue
instance containing the given elements.- Parameters:
elements
- the elements that the queue should contain, in order- Returns:
- a new
PriorityBlockingQueue
containing those elements
newPriorityQueue
public static <E> PriorityQueue<E> newPriorityQueue()
- Creates an empty
PriorityQueue
instance.- Returns:
- a new, empty
PriorityQueue
newPriorityQueue
public static <E> PriorityQueue<E> newPriorityQueue(Iterable<? extends E> elements)
- Creates an
PriorityQueue
instance containing the given elements.- Parameters:
elements
- the elements that the queue should contain, in order- Returns:
- a new
PriorityQueue
containing those elements
newSynchronousQueue
public static <E> SynchronousQueue<E> newSynchronousQueue()
- Creates an empty
SynchronousQueue
instance.- Returns:
- a new, empty
SynchronousQueue
drain
public static <E> int drain(BlockingQueue<E> q, Collection<? super E> buffer, int numElements, long timeout, TimeUnit unit) throws InterruptedException
- Drains the queue as
BlockingQueue.drainTo(Collection, int)
, but if the requestednumElements
elements are not available, it will wait for them up to the specified timeout.- Parameters:
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 ofunit
unit
- aTimeUnit
determining how to interpret the timeout parameter- Returns:
- the number of elements transferred
- Throws:
InterruptedException
- if interrupted while waiting
drainUninterruptibly
public static <E> int 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. In that case, the
operation will continue as usual, and in the end the thread's interruption status will be set
(no
InterruptedException
is thrown).- Parameters:
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 ofunit
unit
- aTimeUnit
determining how to interpret the timeout parameter- Returns:
- the number of elements transferred
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2010-2012. All Rights Reserved.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy