Package rma.util
Class FloatArray
java.lang.Object
rma.util.FloatArray
- All Implemented Interfaces:
AsciiSerializable,FieldAccessor,Serializable,Cloneable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe amount by which the capacity of the vector is automatically incremented when its size becomes greater than its capacity.protected intThe number of valid components in the vector.protected float[]The array buffer into which the components of the vector are stored. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty FloatArray.FloatArray(float[] array) Constructs a new FloatArray with the capacity set to the argument array length then copies the argument array data into the element data array.FloatArray(int initialCapacity) Constructs an empty FloatArray with the specified initial capacity.FloatArray(int initialCapacity, int capacityIncrement) Constructs an empty FloatArray with the specified initial capacity and capacity increment. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(float obj) Adds the specified component to the end of this vector, increasing its size by one.booleanaddAll(FloatArray dv) Appends all of the elements in the specified FloatArray to the end of this FloatArray, in the order that they are returned by the specified FloatArray's Iterator.final voidaddElement(float obj) Adds the specified component to the end of this vector, increasing its size by one.final intcapacity()Returns the current capacity of this vector.voidclear()Removes all components from this vector and sets its size to zero.clone()Returns a clone of this vector.final booleancontains(float elem) Tests if the specified float is a component in this vector.final voidcopyInto(float[] anArray) Copies the components of this FloatArray into the specified array.final floatelementAt(int index) Returns the component at the specified index.floatReturns the total value of all the elementsfinal voidensureCapacity(int minCapacity) Increases the capacity of this FloatArray, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.booleanfinal floatReturns the first component of this vector.floatget(int index) Returns the component at the specified index.getFieldObject(Field fld) Gets the FieldObject attribute of the DoubleArray objectfloatgetMax()floatgetMin()final intindexOf(float elem) Searches for the first occurence of the given argument, testing for equality using==.final intindexOf(float elem, int index) Searches for the first occurence of the given argument, beginning the search atindex, and testing for equality using==.final voidinsertElementAt(float obj, int index) Inserts the specified float as a component in this vector at the specifiedindex.final booleanisEmpty()Tests if this vector has no components.final floatReturns the last component of the vector.final intlastIndexOf(float elem) Returns the index of the last occurrence of the specified float in this vector.final intlastIndexOf(float elem, int index) Searches backwards for the specified float, starting from the specified index, and returns an index to it.booleanremove(float obj) Removes the first occurrence of the argument from this vector.final voidRemoves all components from this vector and sets its size to zero.final booleanremoveElement(float obj) Removes the first occurrence of the argument from this vector.final voidremoveElementAt(int index) Deletes the component at the float index.final voidsetElementAt(float obj, int index) Sets the float at the specifiedindexof this vector to be the specified float.booleansetFieldObject(Field fld, Object fobj) Sets the FieldObject attribute of the DoubleArray objectfinal voidsetSize(int newSize) Sets the size of this vector.final voidsetSize(int newSize, float defaultValue) Sets the size of this vector.final intsize()Returns the number of components in this vector.float[]toArray()Returns an array containing all of the elements in this list in the correct order.toString()Returns a string representation of this array.final voidTrims the capacity of this FloatArray to be the FloatArray's current size.
-
Field Details
-
_elementData
protected float[] _elementDataThe array buffer into which the components of the vector are stored. The capacity of the vector is the length of this array buffer. -
_elementCount
protected int _elementCountThe number of valid components in the vector. -
_capacityIncrement
protected int _capacityIncrementThe amount by which the capacity of the vector is automatically incremented when its size becomes greater than its capacity. If the capacity increment is0, the capacity of the vector is doubled each time it needs to grow.
-
-
Constructor Details
-
FloatArray
public FloatArray(int initialCapacity, int capacityIncrement) Constructs an empty FloatArray with the specified initial capacity and capacity increment.- Parameters:
initialCapacity- the initial capacity of the vector.capacityIncrement- the amount by which the capacity is increased when the vector overflows.
-
FloatArray
public FloatArray(int initialCapacity) Constructs an empty FloatArray with the specified initial capacity.- Parameters:
initialCapacity- the initial capacity of the vector.
-
FloatArray
public FloatArray()Constructs an empty FloatArray. -
FloatArray
public FloatArray(float[] array) Constructs a new FloatArray with the capacity set to the argument array length then copies the argument array data into the element data array.- Parameters:
array-
-
-
Method Details
-
copyInto
public final void copyInto(float[] anArray) Copies the components of this FloatArray into the specified array. The array must be big enough to hold all the ints in this FloatArray.- Parameters:
anArray- the array into which the components get copied.
-
trimToSize
public final void trimToSize()Trims the capacity of this FloatArray to be the FloatArray's current size. An application can use this operation to minimize the storage of a FloatArray. -
ensureCapacity
public final void ensureCapacity(int minCapacity) Increases the capacity of this FloatArray, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.- Parameters:
minCapacity- the desired minimum capacity.
-
setSize
public final void setSize(int newSize) Sets the size of this vector. If the new size is greater than the current size, newRMAConst.UNDEF_FLOATitems are added to the end of the vector. If the new size is less than the current size, all components at indexnewSizeand greater are discarded.- Parameters:
newSize- the new size of this vector.
-
setSize
public final void setSize(int newSize, float defaultValue) Sets the size of this vector. If the new size is greater than the current size, newdefaultValueitems are added to the end of the vector. If the new size is less than the current size, all components at indexnewSizeand greater are discarded.- Parameters:
newSize- the new size of this vector.defaultValue- value to fill new array elements with
-
capacity
public final int capacity()Returns the current capacity of this vector.- Returns:
- the current capacity of this vector.
- Since:
- JDK1.0
-
size
public final int size()Returns the number of components in this vector.- Returns:
- the number of components in this vector.
- Since:
- JDK1.0
-
isEmpty
public final boolean isEmpty()Tests if this vector has no components.- Returns:
trueif this vector has no components;falseotherwise.- Since:
- JDK1.0
-
contains
public final boolean contains(float elem) Tests if the specified float is a component in this vector.- Parameters:
elem- an int.- Returns:
trueif the specified float is a component in this vector;falseotherwise.
-
indexOf
public final int indexOf(float elem) Searches for the first occurence of the given argument, testing for equality using==.- Parameters:
elem- a float.- Returns:
- the index of the first occurrence of the argument in this
vector; returns
-1if the float is not found.
-
indexOf
public final int indexOf(float elem, int index) Searches for the first occurence of the given argument, beginning the search atindex, and testing for equality using==.- Parameters:
elem- a float.index- the index to start searching from.- Returns:
- the index of the first occurrence of the float argument in this
vector at position
indexor later in the vector; returns-1if the int is not found.
-
lastIndexOf
public final int lastIndexOf(float elem) Returns the index of the last occurrence of the specified float in this vector.- Parameters:
elem- the desired component.- Returns:
- the index of the last occurrence of the specified float in this
vector; returns
-1if the float is not found.
-
lastIndexOf
public final int lastIndexOf(float elem, int index) Searches backwards for the specified float, starting from the specified index, and returns an index to it.- Parameters:
elem- the desired component.index- the index to start searching from.- Returns:
- the index of the last occurrence of the specified float in this
vector at position less than
indexin the vector;-1if the float is not found.
-
get
public float get(int index) Returns the component at the specified index. wrapper for elementAt(int);- Parameters:
index- Description- Returns:
- Description
-
elementAt
public final float elementAt(int index) Returns the component at the specified index.- Parameters:
index- an index into this vector.- Returns:
- the component at the specified index.
-
firstElement
public final float firstElement()Returns the first component of this vector.- Returns:
- the first component of this vector.
-
lastElement
public final float lastElement()Returns the last component of the vector.- Returns:
- the last component of the vector, i.e.,
the component at index
size() - 1.
-
setElementAt
public final void setElementAt(float obj, int index) Sets the float at the specifiedindexof this vector to be the specified float. The previous float at that position is discarded.The index must be a value greater than or equal to
0and less than the current size of the vector.- Parameters:
obj- what the float is to be set to.index- the specified index.- See Also:
-
removeElementAt
public final void removeElementAt(int index) Deletes the component at the float index. Each component in this vector with an index greater or equal to the specifiedindexis shifted downward to have an index one smaller than the value it had previously.The index must be a value greater than or equal to
0and less than the current size of the vector.- Parameters:
index- the index of the float to remove.- See Also:
-
insertElementAt
public final void insertElementAt(float obj, int index) Inserts the specified float as a component in this vector at the specifiedindex. Each component in this vector with an index greater or equal to the specifiedindexis shifted upward to have an index one greater than the value it had previously.The index must be a value greater than or equal to
0and less than or equal to the current size of the vector.- Parameters:
obj- the float to insert.index- where to insert the new component.- See Also:
-
add
public void add(float obj) Adds the specified component to the end of this vector, increasing its size by one. The capacity of this vector is increased if its size becomes greater than its capacity. wrapper for addElement(float);- Parameters:
obj- the float to be added
-
addAll
Appends all of the elements in the specified FloatArray to the end of this FloatArray, in the order that they are returned by the specified FloatArray's Iterator. The behavior of this operation is undefined if the specified FloatArray is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified FloatArray is this FloatArray, and this FloatArray is nonempty.)- Parameters:
dv- the elements to be inserted into this list.- Returns:
- true if this list changed as a result of the call.
- Throws:
NullPointerException- if the specified FloatArray is null.
-
addElement
public final void addElement(float obj) Adds the specified component to the end of this vector, increasing its size by one. The capacity of this vector is increased if its size becomes greater than its capacity.- Parameters:
obj- the float to be added.
-
toArray
public float[] toArray()Returns an array containing all of the elements in this list in the correct order.- Returns:
- an array containing all of the elements in this list in the correct order.
-
remove
public boolean remove(float obj) Removes the first occurrence of the argument from this vector. If the float is found in this vector, each component in the vector with an index greater or equal to the float's index is shifted downward to have an index one smaller than the value it had previously. wrapper for removeElement(float)- Parameters:
obj- the float to remove- Returns:
trueif the argument was a component of this vector;falseotherwise.
-
removeElement
public final boolean removeElement(float obj) Removes the first occurrence of the argument from this vector. If the float is found in this vector, each component in the vector with an index greater or equal to the int's index is shifted downward to have an index one smaller than the value it had previously.- Parameters:
obj- the float to be removed.- Returns:
trueif the argument was a component of this vector;falseotherwise.
-
clear
public void clear()Removes all components from this vector and sets its size to zero. wrapper for removeAllElements(); -
removeAllElements
public final void removeAllElements()Removes all components from this vector and sets its size to zero. -
clone
Returns a clone of this vector. -
getMax
public float getMax()- Returns:
- the max value of the elements
-
getMin
public float getMin()- Returns:
- the min value of the elements
-
elementTotal
public float elementTotal()Returns the total value of all the elements -
toString
Returns a string representation of this array. -
equals
-
getFieldObject
Gets the FieldObject attribute of the DoubleArray object- Specified by:
getFieldObjectin interfaceFieldAccessor- Parameters:
fld- Description- Returns:
- The FieldObject value
-
setFieldObject
Sets the FieldObject attribute of the DoubleArray object- Specified by:
setFieldObjectin interfaceFieldAccessor- Parameters:
fld- The new FieldObject valuefobj- The new FieldObject value- Returns:
- Description
-