public class FloatQueue
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
FloatQueue.IntQueueIterable |
static class |
FloatQueue.IntQueueIterator |
Modifier and Type | Field and Description |
---|---|
protected int |
head
Index of first element.
|
int |
size
Number of elements in the queue.
|
protected int |
tail
Index of last element.
|
protected float[] |
values
Contains the values in the queue.
|
Constructor and Description |
---|
FloatQueue()
Creates a new Queue which can hold 16 values without needing to resize backing array.
|
FloatQueue(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 o) |
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.
|
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.
|
protected void |
resize(int newSize)
Resize backing array.
|
java.lang.String |
toString() |
java.lang.String |
toString(java.lang.String separator) |
protected float[] values
protected int head
protected int tail
public int size
public FloatQueue()
public FloatQueue(int initialSize)
public void addLast(float object)
object
- can be nullpublic void addFirst(float object)
object
- can be nulladdLast(float)
public void ensureCapacity(int additional)
protected void resize(int newSize)
public float removeFirst()
java.util.NoSuchElementException
- when queue is emptypublic float removeLast()
java.util.NoSuchElementException
- when queue is emptyremoveFirst()
public int indexOf(float value)
public boolean removeValue(float value)
public float removeIndex(int index)
public boolean notEmpty()
public boolean isEmpty()
public float first()
java.util.NoSuchElementException
- when queue is emptyaddFirst(float)
,
removeFirst()
public float last()
java.util.NoSuchElementException
- when queue is emptyaddLast(float)
,
removeLast()
public float get(int index)
first()
.java.lang.IndexOutOfBoundsException
- when the index is negative or greater or equal than sizepublic void clear()
public java.util.Iterator<java.lang.Float> iterator()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String separator)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object