public class ConcurrentShortQueue extends ShortQueue implements ConcurrentCollection
ShortQueue.ShortQueueIterable, ShortQueue.ShortQueueIterator
Modifier and Type | Field and Description |
---|---|
protected ReadWriteLock |
lock |
head, size, tail, values
Constructor and Description |
---|
ConcurrentShortQueue()
Creates a new Queue which can hold 16 values without needing to resize backing array.
|
ConcurrentShortQueue(int initialSize)
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(short object)
Prepend given object to the head.
|
void |
addLast(short 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 object) |
short |
first()
Returns the first (head) item in the queue (without removing it).
|
short |
get(int index)
Retrieves the value in queue without removing it.
|
ReadWriteLock |
getLock()
Returns the collection's
ReadWriteLock |
int |
hashCode() |
int |
indexOf(short value)
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<java.lang.Short> |
iterator()
Returns an iterator for the items in the queue.
|
short |
last()
Returns the last (tail) item in the queue (without removing it).
|
boolean |
notEmpty()
Returns true if the queue has one or more items.
|
short |
removeFirst()
Remove the first item from the queue.
|
short |
removeIndex(int index)
Removes and returns the item at the specified index.
|
short |
removeLast()
Remove the last item from the queue.
|
boolean |
removeValue(short value)
Removes the first instance of the specified value in the queue.
|
java.lang.String |
toString() |
java.lang.String |
toString(java.lang.String separator) |
resize
protected ReadWriteLock lock
public ConcurrentShortQueue()
public ConcurrentShortQueue(int initialSize)
initialSize
- public void addLast(short object)
addLast
in class ShortQueue
object
- can be nullpublic void addFirst(short object)
addFirst
in class ShortQueue
object
- can be nulladdLast(short)
public void ensureCapacity(int additional)
ensureCapacity
in class ShortQueue
additional
- public short removeFirst()
removeFirst
in class ShortQueue
java.util.NoSuchElementException
- when queue is emptypublic short removeLast()
removeLast
in class ShortQueue
java.util.NoSuchElementException
- when queue is emptyremoveFirst()
public int indexOf(short value)
indexOf
in class ShortQueue
value
- public boolean removeValue(short value)
removeValue
in class ShortQueue
value
- public short removeIndex(int index)
removeIndex
in class ShortQueue
index
- public boolean notEmpty()
notEmpty
in class ShortQueue
public boolean isEmpty()
isEmpty
in class ShortQueue
public short first()
first
in class ShortQueue
java.util.NoSuchElementException
- when queue is emptyaddFirst(short)
,
removeFirst()
public short last()
last
in class ShortQueue
java.util.NoSuchElementException
- when queue is emptyaddLast(short)
,
removeLast()
public short get(int index)
first()
.get
in class ShortQueue
index
- java.lang.IndexOutOfBoundsException
- when the index is negative or greater or equal than sizepublic void clear()
clear
in class ShortQueue
public java.util.Iterator<java.lang.Short> iterator()
iterator
in class ShortQueue
public int hashCode()
hashCode
in class ShortQueue
public boolean equals(java.lang.Object object)
equals
in class ShortQueue
public java.lang.String toString()
toString
in class ShortQueue
public java.lang.String toString(java.lang.String separator)
toString
in class ShortQueue
public ReadWriteLock getLock()
ConcurrentCollection
ReadWriteLock
getLock
in interface ConcurrentCollection
ReadWriteLock