net.jbeans.j3d.data
Class CharArray

java.lang.Object
  extended bynet.jbeans.j3d.data.DataArray
      extended bynet.jbeans.j3d.data.CharArray

public class CharArray
extends DataArray

CharArray is an array of character values.

Version:
$Revision: 1.3 $
Author:
Masahiro Takatsuka (masa@jbeans.net)
See Also:
DataArray

Field Summary
 
Fields inherited from class net.jbeans.j3d.data.DataArray
array, dimension, maxId, size, tupleT
 
Constructor Summary
CharArray()
           
CharArray(DataArray da)
           
CharArray(int dim)
          Construct a new CharArray object.
 
Method Summary
 boolean allocate(int size)
          Allocate memory for this array.
 void copy(DataArray da)
           
 int getDataType()
          Get the data type.
 double getElement(int i, int j)
          Return the data component at the ith tuple and jth component location.
 double[] getTuple(int i)
          Get a pointer to a tuple at the ith location.
 void getTuple(int i, double[] tuple)
          Copy the tuple value into a user-provided array.
 char getValue(int id)
          Get the data at a particular index.
 void insertElement(int i, int j, double c)
          Insert the data component at ith tuple and jth component location.
 int insertNextTuple(double[] tuple)
          Insert (memory allocation performed) the tuple onto the end of the array.
 int insertNextValue(char c)
          Insert data at the end of the array.
 void insertTuple(int i, double[] tuple)
          Insert (memory allocation performed) the tuple into the ith location in the array.
 void insertValue(int id, char c)
          Insert data at a specified position in the array.
 DataArray makeObject()
          Virtual constructor creates object of same type as this object.
protected  java.lang.Object resize(int size)
          resize the array.
 void setArray(char[] array)
          This method lets the user specify data to be held by the array.
 void setElement(int i, int j, double c)
          Set the data component at the ith tuple and jth component location.
 void setNumberOfTuples(int number)
          Set the number of tuples in the array.
 void setNumberOfValues(int number)
          Specify the number of values for this object to hold.
 void setTuple(int i, double[] tuple)
          Set the tuple value at the ith location in the array.
 void setValue(int id, char value)
          Set the data at a particular index.
 
Methods inherited from class net.jbeans.j3d.data.DataArray
ensureSpace, getData, getData, getDimension, getMaxId, getNumberOfTuples, getSize, initialize, reset, setDimension, squeeze
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CharArray

public CharArray(int dim)
Construct a new CharArray object.
 

Parameters:
dim - the dimension of the tuple.

CharArray

public CharArray()

CharArray

public CharArray(DataArray da)
Method Detail

copy

public void copy(DataArray da)
Overrides:
copy in class DataArray

makeObject

public DataArray makeObject()
Virtual constructor creates object of same type as this object.

Specified by:
makeObject in class DataArray

allocate

public boolean allocate(int size)
Allocate memory for this array. Delete old storage only if necessary.

Specified by:
allocate in class DataArray

resize

protected java.lang.Object resize(int size)
resize the array.

Specified by:
resize in class DataArray

getDataType

public int getDataType()
Get the data type.

Overrides:
getDataType in class DataArray
Returns:
the underlying data type.

setNumberOfTuples

public void setNumberOfTuples(int number)
Set the number of tuples in the array. Note that this allocates space depending on the tuple dimension.

Specified by:
setNumberOfTuples in class DataArray
Parameters:
number - the number of tuples.
Returns:
void

getTuple

public double[] getTuple(int i)
Get a pointer to a tuple at the ith location. This is a dangerous method (it is not thread safe since a pointer is returned).

Specified by:
getTuple in class DataArray
Parameters:
i - the index of the ith tuple.
Returns:
an array containing tuple.

getTuple

public void getTuple(int i,
                     double[] tuple)
Copy the tuple value into a user-provided array.

Specified by:
getTuple in class DataArray
Parameters:
i -
tuple -
Returns:
void

setTuple

public void setTuple(int i,
                     double[] tuple)
Set the tuple value at the ith location in the array.

Specified by:
setTuple in class DataArray
Parameters:
i -
tuple -
Returns:
void

insertTuple

public void insertTuple(int i,
                        double[] tuple)
Insert (memory allocation performed) the tuple into the ith location in the array.

Specified by:
insertTuple in class DataArray
Parameters:
i -
tuple -
Returns:
void

insertNextTuple

public int insertNextTuple(double[] tuple)
Insert (memory allocation performed) the tuple onto the end of the array.

Specified by:
insertNextTuple in class DataArray
Parameters:
tuple -
Returns:
the location at which the data was inserted.

getElement

public double getElement(int i,
                         int j)
Return the data component at the ith tuple and jth component location. Note that i is less than NumberOfTuples and j is less than NumberOfComponents.

Overrides:
getElement in class DataArray
Parameters:
i - the index to the ith tuple.
j - the index to the jth element of the tuple.
Returns:
element.

setElement

public void setElement(int i,
                       int j,
                       double c)
Set the data component at the ith tuple and jth component location. Note that i is less than NumberOfTuples and j is less than NumberOfComponents. Make sure enough memory has been allocated (use SetNumberOfTuples() and SetNumberOfComponents()).

Overrides:
setElement in class DataArray
Parameters:
i - the index to the ith tuple.
j - the index to the jth element of the tuple.
c - the element to be set.
Returns:
void

insertElement

public void insertElement(int i,
                          int j,
                          double c)
Insert the data component at ith tuple and jth component location. Note that memory allocation is performed as necessary to hold the data.

Overrides:
insertElement in class DataArray
Returns:
void

getValue

public char getValue(int id)
Get the data at a particular index.


setValue

public void setValue(int id,
                     char value)
Set the data at a particular index. Does not do range checking. Make sure you use the method SetNumberOfValues() before inserting data.


setNumberOfValues

public void setNumberOfValues(int number)
Specify the number of values for this object to hold. Does an allocation as well as setting the MaxId ivar. Used in conjunction with SetValue() method for fast insertion.


insertValue

public void insertValue(int id,
                        char c)
Insert data at a specified position in the array.


insertNextValue

public int insertNextValue(char c)
Insert data at the end of the array. Return its location in the array.


setArray

public void setArray(char[] array)
This method lets the user specify data to be held by the array. The array argument is a pointer to the data. size is the size of the array supplied by the user. Set save to 1 to keep the class from deleting the array when it cleans up or reallocates memory. The class uses the actual array provided; it does not copy the data from the suppled array.



Copyright © 1995-2004 net.jbeans. All Rights Reserved.