public class FloatArray
extends java.lang.Object
Constructor and Description |
---|
FloatArray()
Creates a new expandable array with an initial capacity of 100.
|
FloatArray(int initialCapacity)
Creates a new expandable array with specified initial capacity.
|
Modifier and Type | Method and Description |
---|---|
int |
add(float value)
Appends the specified value to the end of this FloatArray.
|
int |
add(float[] a,
int n)
Appends the first n values from the specified array to this FloatArray.
|
void |
clear()
Removes all elements form this FloatArray.
|
float |
get(int index)
Returns the element at the specified position in this FloatArray.
|
float |
getLast()
Returns the last element of this FloatArray.
|
void |
removeLast(int n)
Deletes the last
n element from this FloatArray. |
float |
set(int index,
float value)
Replaces the element at the specified position with the value given.
|
int |
size()
Returns the number of elements in the array.
|
float[] |
toArray()
Returns a float array containing all elements of this FloatArray.
|
void |
trimToSize()
Trims the capacity of this FloatArray instance to be its current size,
minimizing the storage of the FloatArray instance.
|
public FloatArray()
public FloatArray(int initialCapacity)
java.lang.IllegalArgumentException
- if the specified initial capacity is less than zeropublic int size()
public void clear()
public float[] toArray()
public float get(int index)
java.lang.IndexOutOfBoundsException
- - if index is out of range (index < 0 || index >= size()
).public float getLast()
java.lang.IndexOutOfBoundsException
- - if this FloatArray is emptypublic float set(int index, float value)
java.lang.IndexOutOfBoundsException
- - if index is out of range (index < 0 || index >= size()
).public int add(float value)
public int add(float[] a, int n)
public void removeLast(int n)
n
element from this FloatArray. n
may be larger than the number of elements; in that
case, all elements are removed.public void trimToSize()