Package rma.util
Class DoubleArray
java.lang.Object
rma.util.DoubleArray
- 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 double[]The array buffer into which the components of the vector are stored. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty DoubleArray.DoubleArray(double[] array) Constructs a new DoubleArray with the capacity set to the argument array length then copies the argument array data into the element data array.DoubleArray(int initialCapacity) Constructs an empty DoubleArray with the specified initial capacity.DoubleArray(int initialCapacity, int capacityIncrement) Constructs an empty DoubleArray with the specified initial capacity and capacity increment. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(double obj) Adds the specified component to the end of this vector, increasing its size by one.booleanaddAll(DoubleArray dv) Appends all of the elements in the specified DoubleArray to the end of this DoubleArray, in the order that they are returned by the specified DoubleArray's Iterator.final voidaddElement(double 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(double elem) Tests if the specified double is a component in this vector.final voidcopyInto(double[] anArray) Copies the components of this DoubleArray into the specified array.final doubleelementAt(int index) Returns the component at the specified index.doubleReturns the total value of all the elementsfinal voidensureCapacity(int minCapacity) Increases the capacity of this DoubleArray, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.booleanfinal doubleReturns the first component of this vector.doubleget(int index) Returns the component at the specified index.getFieldObject(Field fld) Gets the FieldObject attribute of the DoubleArray objectdoublegetMax()doublegetMin()final intindexOf(double elem) Searches for the first occurence of the given argument, testing for equality using==.final intindexOf(double elem, int index) Searches for the first occurence of the given argument, beginning the search atindex, and testing for equality using==.final voidinsertElementAt(double obj, int index) Inserts the specified double as a component in this vector at the specifiedindex.final booleanisEmpty()Tests if this vector has no components.final doubleReturns the last component of the vector.final intlastIndexOf(double elem) Returns the index of the last occurrence of the specified double in this vector.final intlastIndexOf(double elem, int index) Searches backwards for the specified double, starting from the specified index, and returns an index to it.booleanremove(double 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(double obj) Removes the first occurrence of the argument from this vector.final voidremoveElementAt(int index) Deletes the component at the double index.final voidsetElementAt(double obj, int index) Sets the double at the specifiedindexof this vector to be the specified double.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, double defaultValue) Sets the size of this vector.final intsize()Returns the number of components in this vector.double[]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 DoubleArray to be the DoubleArray's current size.
-
Field Details
-
_elementData
protected double[] _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
-
DoubleArray
public DoubleArray(int initialCapacity, int capacityIncrement) Constructs an empty DoubleArray 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.
-
DoubleArray
public DoubleArray(int initialCapacity) Constructs an empty DoubleArray with the specified initial capacity.- Parameters:
initialCapacity- the initial capacity of the vector.
-
DoubleArray
public DoubleArray()Constructs an empty DoubleArray. -
DoubleArray
public DoubleArray(double[] array) Constructs a new DoubleArray 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(double[] anArray) Copies the components of this DoubleArray into the specified array. The array must be big enough to hold all the ints in this DoubleArray.- Parameters:
anArray- the array into which the components get copied.
-
trimToSize
public final void trimToSize()Trims the capacity of this DoubleArray to be the DoubleArray's current size. An application can use this operation to minimize the storage of a DoubleArray. -
ensureCapacity
public final void ensureCapacity(int minCapacity) Increases the capacity of this DoubleArray, 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_DOUBLEitems 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, double 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(double elem) Tests if the specified double is a component in this vector.- Parameters:
elem- an int.- Returns:
trueif the specified double is a component in this vector;falseotherwise.
-
indexOf
public final int indexOf(double elem) Searches for the first occurence of the given argument, testing for equality using==.- Parameters:
elem- a double.- Returns:
- the index of the first occurrence of the argument in this
vector; returns
-1if the double is not found.
-
indexOf
public final int indexOf(double elem, int index) Searches for the first occurence of the given argument, beginning the search atindex, and testing for equality using==.- Parameters:
elem- a double.index- the index to start searching from.- Returns:
- the index of the first occurrence of the double argument in this
vector at position
indexor later in the vector; returns-1if the int is not found.
-
lastIndexOf
public final int lastIndexOf(double elem) Returns the index of the last occurrence of the specified double in this vector.- Parameters:
elem- the desired component.- Returns:
- the index of the last occurrence of the specified double in this
vector; returns
-1if the double is not found.
-
lastIndexOf
public final int lastIndexOf(double elem, int index) Searches backwards for the specified double, 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 double in this
vector at position less than
indexin the vector;-1if the double is not found.
-
get
public double get(int index) Returns the component at the specified index. wrapper for elementAt(int);- Parameters:
index- Description- Returns:
- Description
-
elementAt
public final double 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 double firstElement()Returns the first component of this vector.- Returns:
- the first component of this vector.
-
lastElement
public final double 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(double obj, int index) Sets the double at the specifiedindexof this vector to be the specified double. The previous double 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 double is to be set to.index- the specified index.- See Also:
-
removeElementAt
public final void removeElementAt(int index) Deletes the component at the double 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 double to remove.- See Also:
-
insertElementAt
public final void insertElementAt(double obj, int index) Inserts the specified double 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 double to insert.index- where to insert the new component.- See Also:
-
add
public void add(double 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(double);- Parameters:
obj- the double to be added
-
addAll
Appends all of the elements in the specified DoubleArray to the end of this DoubleArray, in the order that they are returned by the specified DoubleArray's Iterator. The behavior of this operation is undefined if the specified DoubleArray is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified DoubleArray is this DoubleArray, and this DoubleArray 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 DoubleArray is null.
-
addElement
public final void addElement(double 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 double to be added.
-
toArray
public double[] 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(double obj) Removes the first occurrence of the argument from this vector. If the double is found in this vector, each component in the vector with an index greater or equal to the double's index is shifted downward to have an index one smaller than the value it had previously. wrapper for removeElement(double)- Parameters:
obj- the double to remove- Returns:
trueif the argument was a component of this vector;falseotherwise.
-
removeElement
public final boolean removeElement(double obj) Removes the first occurrence of the argument from this vector. If the double 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 double 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 double getMax()- Returns:
- the max value of the elements
-
getMin
public double getMin()- Returns:
- the min value of the elements
-
elementTotal
public double 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
-