Class DoubleArrayList
java.lang.Object
math.DoubleArrayList
this class creates a dynamic list of double. it is useful to use when you want
to access the elements randomly, but you have often to cancel the first part of list
or to add elements in the end but in general the size is approximately
constant.
- Author:
- Federico Granata
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of DoubleArrayListDoubleArrayList(double[] data) Creates a new instance of DoubleArrayList initializedDoubleArrayList(int minCapacity) Creates a new instance of DoubleArrayList with a minimum capacity. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(double newD) add a new element at the end of the listvoidclear()It clears all the data inside the List.voiddelFirst(int dim) deletes the first dim data.voidensureCapacity(int dim) Ensures the minimum capacity of the List.doubleget(int pos) Gets the data in position pos.intgetSize()gets the size of the Listvoidset(int pos, double newD) sets the element in position posdouble[]toArray(int startPos, int endPos) creates an array of double that contains the data from startPos to endPos.
-
Constructor Details
-
DoubleArrayList
public DoubleArrayList()Creates a new instance of DoubleArrayList -
DoubleArrayList
public DoubleArrayList(int minCapacity) Creates a new instance of DoubleArrayList with a minimum capacity.- Parameters:
minCapacity- the minimum capcity of the neew list
-
DoubleArrayList
public DoubleArrayList(double[] data) Creates a new instance of DoubleArrayList initialized- Parameters:
data- the array of initializing data
-
-
Method Details
-
add
public boolean add(double newD) add a new element at the end of the list- Parameters:
newD- the new element- Returns:
- true if the operation is successful, false otherwise
-
ensureCapacity
public void ensureCapacity(int dim) Ensures the minimum capacity of the List. If the lists has more element then dim it throws an exception.- Parameters:
dim-
-
clear
public void clear()It clears all the data inside the List. -
get
public double get(int pos) Gets the data in position pos.- Parameters:
pos-- Returns:
- the data
-
delFirst
public void delFirst(int dim) deletes the first dim data.- Parameters:
dim-
-
toArray
public double[] toArray(int startPos, int endPos) creates an array of double that contains the data from startPos to endPos.- Parameters:
startPos-endPos-- Returns:
-
set
public void set(int pos, double newD) sets the element in position pos- Parameters:
pos-newD-
-
getSize
public int getSize()gets the size of the List- Returns:
-