|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.quinncurtis.chart2djava.DoubleArray
public class DoubleArray
The DoubleArray is an improved version of the standard Array type because it allows automatic and dynamic resizing of the array. The array has a Length property that specifies the number of elements in the array, and a maxCapacity property that specifies the size of the internal Array buffer. The internal buffer can be sized much larger than the Length property, allowing the array to grow in length without forcing a time consuming reallocation and the subsequent copying of all of the data values. Not really important if you are dealing with 10 or 20 element arrays, but very important if you have 1,000,000 element arrays.
Constructor Summary | |
---|---|
DoubleArray()
Default constructor. |
|
DoubleArray(double[] x)
Constructor initializes the array using the specified data values. |
|
DoubleArray(double[] x,
int maxcap)
Constructor initializes the array using the specified data values. |
|
DoubleArray(int n)
Constructor creates an array of Length n, initialized to zero. |
Method Summary | |
---|---|
int |
add(double r)
Adds a new element at the end of the array, increasing the length of the array by one. |
int |
addRange(double[] x)
Adds a array of new values at the end of the array, increasing the length of the array by the length of the source array. |
static void |
arrayCopy(double[] source,
int sourceoffset,
double[] dest,
int destoffset,
int count)
|
void |
clear()
Resets (same as clear) the Length property to 0, the maxCapacity property to 16 and reallocates the internal buffer to maxCapacity. |
java.lang.Object |
clone()
Returns an object that is a clone of this array object. |
void |
copy(DoubleArray source)
Copies the source array to the current instance. |
static void |
copyArray(DoubleArray source,
int sourceoffset,
DoubleArray dest,
int destoffset,
int count)
Static routine copies all or part of one array to another. |
double[] |
DataBuffer()
Returns a reference to the Array object that represents internal data buffer. |
int |
delete(int index)
Removes an element at the specified index, decreasing the length of the array by one. |
double[] |
getDataBuffer()
Returns a reference to the Array object that represents internal data buffer. |
double |
getElement(int index)
Get the value of a single element in the array. |
double[] |
getElements()
Returns a copy of the data values in the array sized to the number of elements. |
int |
insert(int index,
double r)
Inserts an element in the array at the specified index, increasing the length of the array by one. |
int |
length()
This accessor returns the value of the length field which is number of data points in a simple dataset, or the number of x-values in a group dataset. |
int |
maxCapacity()
This accessor returns the value of the maxCapacity field. |
void |
nDCopy(DoubleArray source)
Non-Destructive copy does not reallocate buffers, limits copy to the number of elements in the smaller of two arrays, the source or the current instance. |
int |
removeAt(int index)
Removes an element at the specified index, decreasing the length of the array by one. |
void |
reset()
Resets the Length property to 0, the maxCapacity property to 16 and reallocates the internal buffer to maxCapacity. |
int |
resize(int newlength)
The length of the arrays is set to the specified value. |
void |
resizeCapacity(int newcapacity)
This method reallocates the internal data buffer to the new capacity value. |
void |
setElement(int index,
double r)
Set the value of a single element in the array. |
int |
setElements(double[] source)
Initializes the elements of the array, starting at element 0. |
int |
setElements(double[] source,
int count)
Initializes the elements of the array, starting at element 0 and continuing for count elements. |
int |
setElements(DoubleArray source)
Initializes the elements of the array, starting at element 0. |
int |
setElements(DoubleArray source,
int count)
Initializes the elements of the array, starting at element 0 and continuing for count elements. |
int |
setLength(int newlength)
Resizes the array to the specified length. |
void |
shiftLeft(int shiftcount,
boolean fillzero)
Shifts the elements of the array to the left. |
int |
shiftLeftThenResize(int shiftcount,
boolean trim)
Shifts the elements of the array to the left. |
void |
shiftRight(int shiftcount,
boolean fillzero)
Shifts the elements of the array to the right. |
void |
TrimToSize()
The maxCapacity property is set equal to the Length property of the array and the internal buffer are resized to the new maxCapacity value. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DoubleArray()
public DoubleArray(double[] x)
x
- The initializing data values.public DoubleArray(double[] x, int maxcap)
x
- The initializing data values.maxcap
- The internal buffer holding the data values is sized to the value of maxcap.
If the number of datavalues exceeds the maxcap limit, the size of maxcap is automatically doubled.public DoubleArray(int n)
n
- The array is sized to n elements.Method Detail |
---|
public int add(double r)
r
- The new value to add at the end of the array.
public int addRange(double[] x)
x
- An array of new values that are added to the end of the array.
public static void arrayCopy(double[] source, int sourceoffset, double[] dest, int destoffset, int count)
public void clear()
public java.lang.Object clone()
clone
in class java.lang.Object
public void copy(DoubleArray source)
source
- The source array object.public static void copyArray(DoubleArray source, int sourceoffset, DoubleArray dest, int destoffset, int count)
source
- The source array.sourceoffset
- The index to start copying from in the source array.dest
- The destination array.destoffset
- The index to start copying to in the destination array.count
- The number of array elements to copy.public double[] DataBuffer()
public int delete(int index)
index
- The array element that is deleted.
public double[] getDataBuffer()
public double getElement(int index)
index
- The array index.
public double[] getElements()
public int insert(int index, double r)
index
- The array element where the new value is inserted.r
- The new value to insert.
public int length()
public int maxCapacity()
public void nDCopy(DoubleArray source)
source
- The source array object.public int removeAt(int index)
index
- The array element that is deleted.
public void reset()
public int resize(int newlength)
newlength
- The array is resized to the new length.
public void resizeCapacity(int newcapacity)
newcapacity
- The internal buffer holding the data values is sized to the new value of new capacity.
The Length property remains unchanged if the new buffer size is larger than the old buffer size, only the
buffer size is changed, not the current number of elements in the array.public void setElement(int index, double r)
index
- The index to set in the array.r
- The array element at index is set to the value r.*public int setElements(double[] source)
source
- An array of new values used to initialize the array. The
array will end up the same size as the source array.
public int setElements(double[] source, int count)
source
- An array of new values used to initialize the array. The
array will end up the same size as the source array, or the count value, whichever is smaller.count
- Specifies the number of elements to initialize.
public int setElements(DoubleArray source)
source
- An array of new values used to initialize the array. The
array will end up the same size as the source array.
public int setElements(DoubleArray source, int count)
source
- An array of new values used to initialize the array. The
array will end up the same size as the source array, or the count value, whichever is smaller.count
- Specifies the number of elements to initialize.
public int setLength(int newlength)
newlength
- The array is resized to the new length.
public void shiftLeft(int shiftcount, boolean fillzero)
shiftcount
- The elements are shifted to left by shiftcount elements.fillzero
- Set to true if elements to the right of the final shift point are to be set to zero.
In the example above this would apply to elements 8 and 9 in the final, shifted array.public int shiftLeftThenResize(int shiftcount, boolean trim)
shiftcount
- The elements are shifted to left by shiftcount elements.trim
- Set to true if the maxCapacity property is to be set equal to Length property,
sizing the internal data buffers to the exact array size.
public void shiftRight(int shiftcount, boolean fillzero)
shiftcount
- The elements are shifted to right by shiftcount elements.fillzero
- Set to true if elements to the left of the final shift point are to be set to zero.
In the example above this would apply to elements 0 and 1 in the final, shifted array.public void TrimToSize()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |