com.quinncurtis.chart2djava
Class TimeArray

java.lang.Object
  extended by com.quinncurtis.chart2djava.DoubleArray
      extended by com.quinncurtis.chart2djava.TimeArray

public class TimeArray
extends DoubleArray

The TimeArray 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
TimeArray()
          Default constructor.
TimeArray(java.util.GregorianCalendar[] x)
          Constructor initializes the array using the specified data values.
TimeArray(java.util.GregorianCalendar[] x, int maxcap)
          Constructor initializes the array using the specified data values.
TimeArray(int n)
          Constructor creates an array of Length n, initialized to zero.
 
Method Summary
 int add(java.util.GregorianCalendar r)
          Adds a new element at the end of the array, increasing the length of the array by one.
 int addRange(java.util.GregorianCalendar[] 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(java.util.GregorianCalendar[] source, int sourceoffset, double[] dest, int destoffset, int count)
           
 java.lang.Object clone()
          Returns an object that is a clone of this array object.
 void copy(TimeArray source)
          Copies the source array to the current instance.
 java.util.GregorianCalendar[] getTimeDataBuffer()
          Returns a reference to the Array object that represents internal data buffer.
 java.util.GregorianCalendar getTimeElement(int index)
          Get the value of a single element in the array.
 java.util.GregorianCalendar[] getTimeElements()
          Returns a copy of the data values in the array sized to the number of elements.
 void setElement(int index, java.util.GregorianCalendar r)
          Set the value of a single element in the array.
 int setElements(java.util.GregorianCalendar[] source)
          Initializes the elements of the array, starting at element 0.
 int setElements(java.util.GregorianCalendar[] source, int count)
          Initializes the elements of the array, starting at element 0 and continuing for count elements.
 int setElements(TimeArray source)
          Initializes the elements of the array, starting at element 0.
 int setElements(TimeArray source, int count)
          Initializes the elements of the array, starting at element 0 and continuing for count elements.
 java.util.GregorianCalendar[] TimeDataBuffer()
          Returns a reference to the Array object that represents internal data buffer.
 
Methods inherited from class com.quinncurtis.chart2djava.DoubleArray
add, addRange, arrayCopy, clear, copy, copyArray, DataBuffer, delete, getDataBuffer, getElement, getElements, insert, length, maxCapacity, nDCopy, removeAt, reset, resize, resizeCapacity, setElement, setElements, setElements, setElements, setElements, setLength, shiftLeft, shiftLeftThenResize, shiftRight, TrimToSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeArray

public TimeArray()
Default constructor.


TimeArray

public TimeArray(java.util.GregorianCalendar[] x)
Constructor initializes the array using the specified data values. The number of elements of the array is set to the Length of the source array, and the internal buffer used to hold the data is set to the same size.

Parameters:
x - The initializing data values.

TimeArray

public TimeArray(java.util.GregorianCalendar[] x,
                 int maxcap)
Constructor initializes the array using the specified data values. The number of elements of the array is set to the Length of the initializing array, while the internal buffer used to hold the data is sized to maxcap.

Parameters:
x - The initializing data values.
maxcap - The internal buffer holding the data values is sized to the value of maxcap. If the number of data values exceeds the maxcap limit, the size of maxcap is automatically doubled.

TimeArray

public TimeArray(int n)
Constructor creates an array of Length n, initialized to zero.

Parameters:
n - The array is sized to n elements.
Method Detail

add

public int add(java.util.GregorianCalendar r)
Adds a new element at the end of the array, increasing the length of the array by one. If the maxCapacity property is exceeded the maxCapacity property is automatically doubled and the internal buffer resized accordingly.

Parameters:
r - The new value to add at the end of the array.
Returns:
Returns the new value of the Length property.

addRange

public int addRange(java.util.GregorianCalendar[] 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. If the maxCapacity property is exceeded the maxCapacity property is automatically doubled and the internal buffer resized accordingly.

Parameters:
x - An array of new values that are added to the end of the array.
Returns:
Returns the new value of the Length property.

arrayCopy

public static void arrayCopy(java.util.GregorianCalendar[] source,
                             int sourceoffset,
                             double[] dest,
                             int destoffset,
                             int count)

clone

public java.lang.Object clone()
Returns an object that is a clone of this array object.

Overrides:
clone in class DoubleArray
Returns:
Returns a clone of this array object.

copy

public void copy(TimeArray source)
Copies the source array to the current instance.

Parameters:
source - The source array object.

getTimeDataBuffer

public java.util.GregorianCalendar[] getTimeDataBuffer()
Returns a reference to the Array object that represents internal data buffer. It may be sized to the maxCapacity value, instead of the number of items in the buffer. This reference will remain valid only as long as the array is not forced to resize, forcing a reallocation of the internal buffer.

Returns:
Returns a reference to the Array object that represents the internal data buffer.

getTimeElement

public java.util.GregorianCalendar getTimeElement(int index)
Get the value of a single element in the array.

Parameters:
index - The array index.
Returns:
Returns the value of the array at the specified index.

getTimeElements

public java.util.GregorianCalendar[] getTimeElements()
Returns a copy of the data values in the array sized to the number of elements.

Returns:
Returns a copy of the data values in the array sized to the number of elements.

setElement

public void setElement(int index,
                       java.util.GregorianCalendar r)
Set the value of a single element in the array.

Parameters:
index - The index to set in the array.
r - The array element at index is set to the value r.*

setElements

public int setElements(java.util.GregorianCalendar[] source)
Initializes the elements of the array, starting at element 0. The size of the array is set equal to the length of the source array. If the source array is larger than the current length of the array, the array is resized accordingly.

Parameters:
source - An array of new values used to initialize the array. The array will end up the same size as the source array.
Returns:
Returns the new value of the Length property.

setElements

public int setElements(java.util.GregorianCalendar[] source,
                       int count)
Initializes the elements of the array, starting at element 0 and continuing for count elements. The size of the array is set equal to the length of the source array, or the count, whichever is smaller. If the new length larger than the current length of the array, the array is resized accordingly.

Parameters:
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.
Returns:
Returns the new value of the Length property.

setElements

public int setElements(TimeArray source)
Initializes the elements of the array, starting at element 0. The size of the array is set equal to the length of the source array. If the source array is larger than the current length of the array, the array is resized accordingly.

Parameters:
source - An array of new values used to initialize the array. The array will end up the same size as the source array.
Returns:
Returns the new value of the Length property.

setElements

public int setElements(TimeArray source,
                       int count)
Initializes the elements of the array, starting at element 0 and continuing for count elements. The size of the array is set equal to the length of the source array, or the count, whichever is smaller. If the new length larger than the current length of the array, the array is resized accordingly.

Parameters:
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.
Returns:
Returns the new value of the Length property.

TimeDataBuffer

public java.util.GregorianCalendar[] TimeDataBuffer()
Returns a reference to the Array object that represents internal data buffer. This reference will remain valid only as long as the array is not forced to resize, forcing a reallocation of the internal buffer.