Package org.opensourcephysics.media.core
Class DoubleArray
java.lang.Object
org.opensourcephysics.media.core.DoubleArray
This manages an array of doubles.
- Version:
- 1.0
- Author:
- Douglas Brown
-
Constructor Summary
ConstructorsConstructorDescriptionDoubleArray
(int initialLength, double initialValue) Constructs a DoubleArray object. -
Method Summary
Modifier and TypeMethodDescriptionboolean
fill
(double value) Fills elements of the array with the specified value.boolean
fill
(double value, int start, int end) Fills a subset of elements of the array with the specified value.double
get
(int n) Gets the specified array element.boolean
set
(int n, double value) Sets the specified array element.void
setLength
(int newLength) Sets the length of the array.
-
Constructor Details
-
DoubleArray
public DoubleArray(int initialLength, double initialValue) Constructs a DoubleArray object.- Parameters:
initialLength
- the initial length of the arrayinitialValue
- the initial value of all array elements
-
-
Method Details
-
get
public double get(int n) Gets the specified array element.- Parameters:
n
- the array index- Returns:
- the value at the specified index
-
set
public boolean set(int n, double value) Sets the specified array element.- Parameters:
n
- the array indexvalue
- the new value of the element- Returns:
- true if element was changed
-
setLength
public void setLength(int newLength) Sets the length of the array.- Parameters:
newLength
- the new length of the array
-
fill
public boolean fill(double value) Fills elements of the array with the specified value.- Parameters:
value
- the value- Returns:
- true if at least one element was changed
-
fill
public boolean fill(double value, int start, int end) Fills a subset of elements of the array with the specified value.- Parameters:
value
- the valuestart
- the first indexend
- the last index- Returns:
- true if at least one element was changed
-