public class ConcurrentQueue<T> extends org.mini2Dx.gdx.utils.Queue<T> implements ConcurrentCollection
| Modifier and Type | Field and Description |
|---|---|
protected ReadWriteLock |
lock |
| Constructor and Description |
|---|
ConcurrentQueue()
Creates a new Queue which can hold 16 values without needing to resize backing array.
|
ConcurrentQueue(int initialSize)
Creates a new Queue which can hold the specified number of values without needing to resize backing array.
|
ConcurrentQueue(int initialSize,
java.lang.Class<T> type)
Creates a new Queue which can hold the specified number of values without needing to resize backing array.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFirst(T object)
Prepend given object to the head.
|
void |
addLast(T object)
Append given object to the tail.
|
void |
clear()
Removes all values from this queue.
|
void |
ensureCapacity(int additional)
Increases the size of the backing array to accommodate the specified number of additional items.
|
boolean |
equals(java.lang.Object obj) |
boolean |
equalsIdentity(java.lang.Object o)
Uses == for comparison of each item.
|
T |
first()
Returns the first (head) item in the queue (without removing it).
|
T |
get(int index)
Retrieves the value in queue without removing it.
|
ReadWriteLock |
getLock()
Returns the collection's
ReadWriteLock |
int |
hashCode() |
int |
indexOf(T value,
boolean identity)
Returns the index of first occurrence of value in the queue, or -1 if no such value exists.
|
boolean |
isEmpty()
Returns true if the queue is empty.
|
java.util.Iterator<T> |
iterator()
Returns an iterator for the items in the queue.
|
T |
last()
Returns the last (tail) item in the queue (without removing it).
|
boolean |
notEmpty()
Returns true if the queue has one or more items.
|
T |
removeFirst()
Remove the first item from the queue.
|
T |
removeIndex(int index)
Removes and returns the item at the specified index.
|
T |
removeLast()
Remove the last item from the queue.
|
boolean |
removeValue(T value,
boolean identity)
Removes the first instance of the specified value in the queue.
|
java.lang.String |
toString() |
protected ReadWriteLock lock
public ConcurrentQueue()
public ConcurrentQueue(int initialSize)
initialSize - public ConcurrentQueue(int initialSize,
java.lang.Class<T> type)
initialSize - type - public void addLast(T object)
addLast in class org.mini2Dx.gdx.utils.Queue<T>object - can be nullpublic void addFirst(T object)
addFirst in class org.mini2Dx.gdx.utils.Queue<T>object - can be nulladdLast(Object)public void ensureCapacity(int additional)
ensureCapacity in class org.mini2Dx.gdx.utils.Queue<T>additional - public T removeFirst()
removeFirst in class org.mini2Dx.gdx.utils.Queue<T>java.util.NoSuchElementException - when queue is emptypublic T removeLast()
removeLast in class org.mini2Dx.gdx.utils.Queue<T>java.util.NoSuchElementException - when queue is emptyremoveFirst()public int indexOf(T value, boolean identity)
indexOf in class org.mini2Dx.gdx.utils.Queue<T>value - identity - If true, == comparison will be used. If false, .equals() comparison will be used.public boolean removeValue(T value, boolean identity)
removeValue in class org.mini2Dx.gdx.utils.Queue<T>value - identity - If true, == comparison will be used. If false, .equals() comparison will be used.public T removeIndex(int index)
removeIndex in class org.mini2Dx.gdx.utils.Queue<T>index - public boolean notEmpty()
notEmpty in class org.mini2Dx.gdx.utils.Queue<T>public boolean isEmpty()
isEmpty in class org.mini2Dx.gdx.utils.Queue<T>public T first()
first in class org.mini2Dx.gdx.utils.Queue<T>java.util.NoSuchElementException - when queue is emptyaddFirst(Object),
removeFirst()public T last()
last in class org.mini2Dx.gdx.utils.Queue<T>java.util.NoSuchElementException - when queue is emptyaddLast(Object),
removeLast()public T get(int index)
first().get in class org.mini2Dx.gdx.utils.Queue<T>index - java.lang.IndexOutOfBoundsException - when the index is negative or greater or equal than sizepublic void clear()
clear in class org.mini2Dx.gdx.utils.Queue<T>public java.util.Iterator<T> iterator()
public int hashCode()
hashCode in class org.mini2Dx.gdx.utils.Queue<T>public boolean equals(java.lang.Object obj)
equals in class org.mini2Dx.gdx.utils.Queue<T>public java.lang.String toString()
toString in class org.mini2Dx.gdx.utils.Queue<T>public boolean equalsIdentity(java.lang.Object o)
equalsIdentity in class org.mini2Dx.gdx.utils.Queue<T>o - public ReadWriteLock getLock()
ConcurrentCollectionReadWriteLockgetLock in interface ConcurrentCollectionReadWriteLock