E - The element typepublic class BlockingArrayQueue<E>
extends java.util.AbstractList<E>
implements java.util.concurrent.BlockingQueue<E>
This queue is uses a variant of the two lock queue algorithm to provide an efficient queue or list backed by a growable circular array.
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 max capacity (the maximum size that may be allocated), which defaults to
Integer.MAX_VALUE.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_CAPACITY
Default initial capacity, 128.
|
static int |
DEFAULT_GROWTH
Default growth factor, 64.
|
| Constructor and Description |
|---|
BlockingArrayQueue()
Creates an unbounded
BlockingArrayQueue with default initial capacity and grow factor. |
BlockingArrayQueue(int maxCapacity)
Creates a bounded
BlockingArrayQueue that does not grow. |
BlockingArrayQueue(int capacity,
int growBy)
Creates an unbounded
BlockingArrayQueue that grows by the given parameter. |
BlockingArrayQueue(int capacity,
int growBy,
int maxCapacity)
Create a bounded
BlockingArrayQueue that grows by the given parameter. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
void |
add(int index,
E e) |
void |
clear() |
int |
drainTo(java.util.Collection<? super E> c) |
int |
drainTo(java.util.Collection<? super E> c,
int maxElements) |
E |
element() |
E |
get(int index) |
int |
getCapacity() |
int |
getMaxCapacity() |
java.util.Iterator<E> |
iterator() |
java.util.ListIterator<E> |
listIterator(int index) |
boolean |
offer(E e) |
boolean |
offer(E o,
long timeout,
java.util.concurrent.TimeUnit unit) |
E |
peek() |
E |
poll() |
E |
poll(long time,
java.util.concurrent.TimeUnit unit) |
void |
put(E o) |
int |
remainingCapacity() |
E |
remove() |
E |
remove(int index) |
boolean |
remove(java.lang.Object o) |
E |
set(int index,
E e) |
int |
size() |
E |
take() |
addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subListaddAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitpublic static final int DEFAULT_CAPACITY
public static final int DEFAULT_GROWTH
public BlockingArrayQueue()
BlockingArrayQueue with default initial capacity and grow factor.DEFAULT_CAPACITY,
DEFAULT_GROWTHpublic BlockingArrayQueue(int maxCapacity)
BlockingArrayQueue that does not grow. The capacity of the queue is fixed and equal to the given parameter.maxCapacity - the maximum capacitypublic BlockingArrayQueue(int capacity,
int growBy)
BlockingArrayQueue that grows by the given parameter.capacity - the initial capacitygrowBy - the growth factorpublic BlockingArrayQueue(int capacity,
int growBy,
int maxCapacity)
BlockingArrayQueue that grows by the given parameter.capacity - the initial capacitygrowBy - the growth factormaxCapacity - the maximum capacitypublic void clear()
public int size()
public java.util.Iterator<E> iterator()
public boolean offer(E e)
public boolean add(E e)
public void put(E o) throws java.lang.InterruptedException
put in interface java.util.concurrent.BlockingQueue<E>java.lang.InterruptedExceptionpublic boolean offer(E o, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
offer in interface java.util.concurrent.BlockingQueue<E>java.lang.InterruptedExceptionpublic E take() throws java.lang.InterruptedException
take in interface java.util.concurrent.BlockingQueue<E>java.lang.InterruptedExceptionpublic E poll(long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
poll in interface java.util.concurrent.BlockingQueue<E>java.lang.InterruptedExceptionpublic boolean remove(java.lang.Object o)
public int remainingCapacity()
remainingCapacity in interface java.util.concurrent.BlockingQueue<E>public int drainTo(java.util.Collection<? super E> c)
drainTo in interface java.util.concurrent.BlockingQueue<E>public int drainTo(java.util.Collection<? super E> c, int maxElements)
drainTo in interface java.util.concurrent.BlockingQueue<E>public E get(int index)
public void add(int index,
E e)
public E remove(int index)
public java.util.ListIterator<E> listIterator(int index)
public int getCapacity()
public int getMaxCapacity()
Copyright © 1995–2018 Webtide. All rights reserved.