net.jbeans.j3d.data
Class BitArray

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

public class BitArray
extends DataArray

BitArray is an array of bits (0/1 data value).

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
BitArray()
           
BitArray(DataArray da)
           
BitArray(int dim)
          Construct a new BitArray object.
 
Method Summary
 boolean allocate(int size)
          Allocate memory for this array.
 void copy(DataArray da)
           
 boolean getBit(int id)
           
 int getDataType()
          Get the data type.
 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.
 int getValue(int id)
          Get the data at a particular index.
 void insertBit(int id, boolean value)
           
 int insertNextBit(boolean value)
           
 int insertNextTuple(double[] tuple)
          Insert (memory allocation performed) the tuple onto the end of the array.
 int insertNextValue(int i)
          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, int i)
          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(byte[] array)
          This method lets the user specify data to be held by the array.
 void setBit(int id, boolean value)
           
 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, int value)
          Set the data at a particular index.
 
Methods inherited from class net.jbeans.j3d.data.DataArray
ensureSpace, getData, getData, getDimension, getElement, getMaxId, getNumberOfTuples, getSize, initialize, insertElement, reset, setDimension, setElement, squeeze
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitArray

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

Parameters:
dim - the dimension of the tuple.

BitArray

public BitArray()

BitArray

public BitArray(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.

getValue

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


getBit

public boolean getBit(int id)

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.


setValue

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


setBit

public void setBit(int id,
                   boolean value)

insertValue

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


insertBit

public void insertBit(int id,
                      boolean value)

insertNextValue

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


insertNextBit

public int insertNextBit(boolean value)

setArray

public void setArray(byte[] 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.