|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.quinncurtis.chart2djava.DoubleArray2D
public class DoubleArray2D
The DoubleArray2D is an improved version of the standard Array type because it allows automatic and dynamic resizing of a 2D array. The array has a NumColumns property that specifies the number of columns in the 2D array, and a NumRows properties the specifies the number of rows in the 2D array. Internally the data buffer is setup as an Array of DoubleArray objects. The rowCapacity property specifies the size of the internal Array buffer that holds a collection of DoubleArray objects. The internal buffer can be sized much larger than the NumRows property, allowing the array to grow in without forcing a time consuming reallocation and the subsequent copying of all of the data values.
Constructor Summary | |
---|---|
DoubleArray2D()
Default constructor. |
|
DoubleArray2D(double[][] rc)
Constructor initializes the array using the specified data values. |
|
DoubleArray2D(double[][] rc,
int colmaxcap)
Constructor initializes the array using the specified data values. |
|
DoubleArray2D(int rows,
int columns)
Constructor creates an array of Length n, initialized to zero. |
Method Summary | |
---|---|
int |
addColumn(double[] r)
Adds a new column of data to the end of the array, increasing the number of columns by one. |
int |
addColumn(DoubleArray r)
Adds a new column of data to the end of the array, increasing the number of columns by one. |
int |
addColumnRange(double[][] rc)
Adds multiple new columns of data to the end of the array, increasing the number of columns by by the number of columns in the source data array. |
int |
addRow(double[] r)
Adds a new row of data to the end of the array, increasing the number of rows by one. |
int |
addRow(DoubleArray r)
Adds a new row of data to the end of the array, increasing the number of rows by one. |
static void |
arrayCopy(double[][] source,
int sourcerow,
int sourcecol,
double[][] dest,
int destrow,
int destcol,
int count)
|
static void |
arrayCopy(double[][] source,
int sourcerow,
int sourcecol,
double[] dest,
int destcol,
int count)
|
static void |
arrayCopy(double[] source,
int sourcecol,
double[][] dest,
int destrow,
int destcol,
int count)
|
void |
clear()
Resets the NumColumns and NumRows properties to 0. |
java.lang.Object |
clone()
Returns an object that is a clone of this array object. |
void |
copy(DoubleArray2D source)
Copies the source array. |
static void |
copyArray(DoubleArray2D source,
int sourcerow,
int sourceoffset,
DoubleArray2D dest,
int destrow,
int destoffset,
int count)
Static routine copies a row of a DoubleArray2D to a row of another DoubleArray2D. |
static void |
copyArray(DoubleArray2D source,
int sourcerow,
int sourceoffset,
DoubleArray dest,
int destoffset,
int count)
Static routine copies a row of a DoubleArray2D to a DoubleArray. |
static void |
copyArray(DoubleArray source,
int sourceoffset,
DoubleArray2D dest,
int destrow,
int destoffset,
int count)
Static routine copies a row of a DoubleArray2D to a DoubleArray. |
DoubleArray[] |
DataBuffer()
This method returns a reference to the internal dataBuffer. |
int |
deleteColumn(int index)
Removes a column in the array at the specified column index, decreasing the NumColumns property of the array by one. |
int |
deleteRow(int index)
Removes a row in the array at the specified row index, decreasing the NumRows property of the array by one. |
double[] |
getColumn(int column)
Returns all of the row values in the specified column. |
double |
getElement(int row,
int col)
Returns the value of the array element at the specified row and column. |
double[][] |
getElements()
Returns the elements of the array as an Array object. |
int |
getLength(int dim)
Returns the size for each dimension of the array. |
int |
getNumColumns()
Returns the current number of columns in the array. |
int |
getNumRows()
Returns the current number of rows in the array. |
double[] |
getRow(int row)
Returns all of the column values in the specified row. |
DoubleArray |
getRowObject(int row)
Returns a reference to the DoubleArray object that holds the data for the given row. |
int |
insertColumn(int index,
double[] r)
Inserts a column in the array at the specified column index, increasing the NumColumns property of the array by one. |
int |
insertColumn(int index,
DoubleArray r)
Inserts a column in the array at the specified column index, increasing the NumColumns property of the array by one. |
int |
insertRow(int index,
double[] r)
Inserts a new row of data at the specified index, increasing the number of rows by one. |
int |
insertRow(int index,
DoubleArray r)
Inserts a new row of data at the specified index, increasing the number of rows by one. |
int |
length()
This method returns the number of elements in the array, NumRows * NumColumns. |
int |
numColumns()
Returns the number of columns in the array. |
int |
numRows()
Returns the number of rows in the array. |
int |
removeColumnAt(int index)
Removes a column in the array at the specified column index, decreasing the NumColumns property of the array by one. |
int |
removeRowAt(int index)
Removes a row in the array at the specified row index, decreasing the NumRows property of the array by one. |
void |
reset()
Resets the NumColumns and NumRows properties to 0. |
void |
resizeColumnCapacity(int newcolcapacity)
This method reallocates the internal column data buffers, where each row of the array is represented by an ArrayDouble object, to the new column capacity value. |
int |
resizeNumColumns(int newnumcols)
Resizes the number of columns in the 2D array. |
int |
resizeNumRows(int newlength)
Resizes the number of rows in the 2D array. |
void |
resizeRowCapacity(int newcapacity)
This method reallocates the size of the internal row data buffers. |
void |
setColumn(int column,
double[] source)
Sets all of the row values in the specified column. |
void |
setColumn(int column,
DoubleArray source)
Sets all of the row values in the specified column. |
void |
setElement(int row,
int col,
double r)
Sets the value of a specific element in the 2D array. |
void |
setElements(double[][] source)
Sets the elements of the array. |
void |
setElements(DoubleArray2D source)
Sets the elements of the array. |
void |
setRow(int row,
double[] source)
Sets all of the column values in the specified row. |
void |
setRow(int row,
DoubleArray source)
Sets all of the column values in the specified row. |
void |
shiftLeft(int shiftcount,
boolean fillzero)
Shifts the column elements of each row of the array to the left. |
int |
shiftLeftThenResize(int shiftcount,
boolean trim)
Shifts the column elements of each row of the array to the left. |
void |
shiftRight(int shiftcount,
boolean fillzero)
Shifts the column elements of each row of the array to the right. |
void |
TrimToSize()
The RowCapacity property is set equal to the NumRows property of the array and the internal buffer is resized to the new RowCapacity value. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DoubleArray2D()
public DoubleArray2D(double[][] rc)
rc
- The initializing data values.public DoubleArray2D(double[][] rc, int colmaxcap)
rc
- The initializing data values.colmaxcap
- The rowCapacity property of each rows DoubleArray object is set to this value.public DoubleArray2D(int rows, int columns)
rows
- The number of rows for the 2D array.columns
- The number of columns for the 2D array.Method Detail |
---|
public int addColumn(double[] r)
r
- A new column of data, size[NumRows], added at the end of the array.
public int addColumn(DoubleArray r)
r
- A new column of data, size[NumRows], added at the end of the array.
public int addColumnRange(double[][] rc)
rc
- A 2D array of new column data, with the number of rows equal to NumRows,
added at the end of the array.
public int addRow(double[] r)
r
- A new row of data, size[NumColumns], added at the end of the array.
public int addRow(DoubleArray r)
r
- A new row of data, size[NumColumns], added at the end of the array.
public static void arrayCopy(double[][] source, int sourcerow, int sourcecol, double[][] dest, int destrow, int destcol, int count)
public static void arrayCopy(double[][] source, int sourcerow, int sourcecol, double[] dest, int destcol, int count)
public static void arrayCopy(double[] source, int sourcecol, double[][] dest, int destrow, int destcol, int count)
public void clear()
public java.lang.Object clone()
clone
in class java.lang.Object
public void copy(DoubleArray2D source)
source
- The source array object.public static void copyArray(DoubleArray2D source, int sourcerow, int sourceoffset, DoubleArray2D dest, int destrow, int destoffset, int count)
source
- The source DoubleArray2D array.sourcerow
- The row of the source array to copy from.sourceoffset
- The column offset to start copying from in the source array.dest
- The destination DoubleArray array.destrow
- The row of the destination array to copy to.destoffset
- The index to start copying to in the destination array.count
- The number of array elements to copy.public static void copyArray(DoubleArray2D source, int sourcerow, int sourceoffset, DoubleArray dest, int destoffset, int count)
source
- The source DoubleArray2D array.sourcerow
- The row of the source array to copy from.sourceoffset
- The column offset to start copying from in the source array.dest
- The destination DoubleArray array.destoffset
- The index to start copying to in the destination array.count
- The number of array elements to copy.public static void copyArray(DoubleArray source, int sourceoffset, DoubleArray2D dest, int destrow, int destoffset, int count)
source
- The source DoubleArray2D array.sourceoffset
- The column offset to start copying from in the source array.dest
- The destination DoubleArray array.destrow
- The row of the destination array to copy to.destoffset
- The index to start copying to in the destination array.count
- The number of array elements to copy.public DoubleArray[] DataBuffer()
public int deleteColumn(int index)
index
- The array column to be deleted.
public int deleteRow(int index)
index
- The array row to be deleted.
public double[] getColumn(int column)
column
- The column index
public double getElement(int row, int col)
row
- The row indexcol
- The column index
public double[][] getElements()
public int getLength(int dim)
dim
- A value of 0 returns the number of rows in the array, a value of 1 returns the
number of columns in the array.
public int getNumColumns()
public int getNumRows()
public double[] getRow(int row)
row
- The row index
public DoubleArray getRowObject(int row)
row
- The row index
public int insertColumn(int index, double[] r)
index
- The array column where the new values are inserted.r
- An array (size NumRows) of new values to insert.
public int insertColumn(int index, DoubleArray r)
index
- The array column where the new values are inserted.r
- An array (size NumRows) of new values to insert.
public int insertRow(int index, double[] r)
index
- Insert the new data at this row index.r
- A new row of data, size[NumColumns], inserted at the specified index.
public int insertRow(int index, DoubleArray r)
index
- Insert the new data at this row index.r
- A new row of data, size[NumColumns], inserted at the specified index.
public int length()
public int numColumns()
public int numRows()
public int removeColumnAt(int index)
index
- The array column to be deleted.
public int removeRowAt(int index)
index
- The array row to be deleted.
public void reset()
public void resizeColumnCapacity(int newcolcapacity)
newcolcapacity
- The internal DoubleArray objects are resized to the new capacity.
The NumColumns property remains unchanged if the new capacity is larger than the old capacity, only the
buffer size is changed, not the current number of columns in the array.public int resizeNumColumns(int newnumcols)
newnumcols
- The number of columns in the array is resized to this value.
public int resizeNumRows(int newlength)
newlength
- The number of rows in the array is resized to this value.
public void resizeRowCapacity(int newcapacity)
newcapacity
- This method reallocates the size of the internal row data buffer.
The NumRows property remains unchanged if the new capacity is larger than the old capacity, only the
row buffer size is changed, not the current number of rows in the array.public void setColumn(int column, double[] source)
column
- The column indexsource
- The source array, size[NumRows], to copy to the specified column.public void setColumn(int column, DoubleArray source)
column
- The column indexsource
- The source array, size[NumRows], to copy to the specified column.public void setElement(int row, int col, double r)
row
- The row indexcol
- The column index *r
- The value to assign the specified array element.public void setElements(double[][] source)
source
- The source 2D Array object.public void setElements(DoubleArray2D source)
source
- The source 2D Array object.public void setRow(int row, double[] source)
row
- The row indexsource
- The source array, size[NumColumns], to copy to the specified row.public void setRow(int row, DoubleArray source)
row
- The row indexsource
- The source array, size[NumColumns], to copy to the specified row.public void shiftLeft(int shiftcount, boolean fillzero)
shiftcount
- The columns are shifted to left by shiftcount elements.fillzero
- Set to true if columns to the right of the final shift point are to be set to zero.
In the example above this would apply to columns 8 and 9 in the final, shifted array.public int shiftLeftThenResize(int shiftcount, boolean trim)
shiftcount
- The columns are shifted to left by shiftcount elements.trim
- Set to true if each rows maxCapacity property is to be set equal to that rows Length
(or NumColumns) property, sizing the internal data buffers to the exact array size.
public void shiftRight(int shiftcount, boolean fillzero)
shiftcount
- The columns are shifted to right by shiftcount elements.fillzero
- Set to true if columns to the left of the final shift point are to be set to zero.
In the example above this would apply to columns 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 |