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