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