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