E - The element typepublic class BlockingArrayQueue<E> extends AbstractList<E> implements BlockingQueue<E>
BlockingQueue, specifically the take() and
poll(long, TimeUnit) methods.
Unlike ArrayBlockingQueue, this class is
able to grow and provides a blocking put call.
The queue has both a capacity (the size of the array currently allocated)
and a limit (the maximum size that may be allocated), which defaults to
Integer.MAX_VALUE.
| Modifier and Type | Field and Description |
|---|---|
int |
DEFAULT_CAPACITY |
int |
DEFAULT_GROWTH |
modCount| Constructor and Description |
|---|
BlockingArrayQueue()
Create a growing partially blocking Queue
|
BlockingArrayQueue(int limit)
Create a fixed size partially blocking Queue
|
BlockingArrayQueue(int capacity,
int growBy)
Create a growing partially blocking Queue.
|
BlockingArrayQueue(int capacity,
int growBy,
int limit)
Create a growing limited partially blocking Queue.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
void |
add(int index,
E e) |
void |
clear() |
int |
drainTo(Collection<? super E> c) |
int |
drainTo(Collection<? super E> c,
int maxElements) |
E |
element() |
E |
get(int index) |
int |
getCapacity() |
int |
getLimit() |
boolean |
isEmpty() |
boolean |
offer(E e) |
boolean |
offer(E o,
long timeout,
TimeUnit unit) |
E |
peek() |
E |
poll() |
E |
poll(long time,
TimeUnit unit)
Retrieves and removes the head of this queue, waiting
if necessary up to the specified wait time if no elements are
present on this queue.
|
void |
put(E o) |
int |
remainingCapacity() |
E |
remove() |
E |
remove(int index) |
E |
set(int index,
E e) |
int |
size() |
E |
take()
Retrieves and removes the head of this queue, waiting
if no elements are present on this queue.
|
addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListaddAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitcontains, removeaddAll, containsAll, equals, hashCode, iterator, removeAll, retainAll, toArray, toArraypublic final int DEFAULT_CAPACITY
public final int DEFAULT_GROWTH
public BlockingArrayQueue()
public BlockingArrayQueue(int limit)
limit - The initial capacity and the limit.public BlockingArrayQueue(int capacity,
int growBy)
capacity - Initial capacitygrowBy - Incremental capacity.public BlockingArrayQueue(int capacity,
int growBy,
int limit)
capacity - Initial capacitygrowBy - Incremental capacity.limit - maximum capacity.public int getCapacity()
public int getLimit()
public boolean add(E e)
add in interface Collection<E>add in interface BlockingQueue<E>add in interface List<E>add in interface Queue<E>add in class AbstractList<E>public boolean offer(E e)
public E take() throws InterruptedException
take in interface BlockingQueue<E>InterruptedException - if interrupted while waiting.public E poll(long time, TimeUnit unit) throws InterruptedException
poll in interface BlockingQueue<E>time - how long to wait before giving up, in units of
unitunit - a TimeUnit determining how to interpret the
timeout parameterInterruptedException - if interrupted while waiting.public void clear()
clear in interface Collection<E>clear in interface List<E>clear in class AbstractList<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface List<E>isEmpty in class AbstractCollection<E>public int size()
size in interface Collection<E>size in interface List<E>size in class AbstractCollection<E>public E get(int index)
public E remove(int index)
public void add(int index,
E e)
public int drainTo(Collection<? super E> c)
drainTo in interface BlockingQueue<E>public int drainTo(Collection<? super E> c, int maxElements)
drainTo in interface BlockingQueue<E>public boolean offer(E o, long timeout, TimeUnit unit) throws InterruptedException
offer in interface BlockingQueue<E>InterruptedExceptionpublic void put(E o) throws InterruptedException
put in interface BlockingQueue<E>InterruptedExceptionpublic int remainingCapacity()
remainingCapacity in interface BlockingQueue<E>Copyright © 1995-2015 Mort Bay Consulting. All Rights Reserved.