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