iicm.vrml.pwutils
Class IntArray

java.lang.Object
  |
  +--iicm.vrml.pwutils.IntArray

public class IntArray
extends java.lang.Object

IntArray - dynamic array of int type values better time and memory efficiency than Vector, int[] accessible in native code Copyright (c) 1996 IICM


Constructor Summary
IntArray()
          create with default length
IntArray(int len)
          create with initial buffer length
IntArray(int[] dat)
          copy initial data from another int[].
IntArray(IntArray dat)
          copy initial data from another IntArray (non-null). do not use the above constructor in this case, as it would use all values, not just the used length (count); again: values are *copied*
 
Method Summary
 void append(int d)
          append one int element
 void append(int[] d, int num)
          append several int elements
 boolean clearData()
          clear the array
 int getCount()
          get count of used array members.
 int[] getData()
          get data array.
 int[] getTrimmedArray()
          get data array with proper length.
 void setData(int[] dat)
          copy data from a int[]
 void setData(int[] dat, int n)
          copy first n elements of a int[]
 void setData(IntArray dat)
          copy data from another IntArray
 void setSize(int n)
          set number of used array elements (ensures there is enough storage)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntArray

public IntArray()
create with default length

IntArray

public IntArray(int len)
create with initial buffer length

IntArray

public IntArray(int[] dat)
copy initial data from another int[]. To say it again: values in int[] are *copied* and not just referenced by this class

IntArray

public IntArray(IntArray dat)
copy initial data from another IntArray (non-null). do not use the above constructor in this case, as it would use all values, not just the used length (count); again: values are *copied*
Method Detail

setData

public void setData(IntArray dat)
copy data from another IntArray

setData

public void setData(int[] dat)
copy data from a int[]

setData

public void setData(int[] dat,
                    int n)
copy first n elements of a int[]

getCount

public final int getCount()
get count of used array members. Note: may be smaller than data_.length

getData

public final int[] getData()
get data array. Only elements 0 to (getCount () - 1) were set by user. Subsequent calls (after enlargement) may return a different array object

getTrimmedArray

public final int[] getTrimmedArray()
get data array with proper length. May involve copying

append

public void append(int d)
append one int element

append

public void append(int[] d,
                   int num)
append several int elements

setSize

public void setSize(int n)
set number of used array elements (ensures there is enough storage)

clearData

public boolean clearData()
clear the array
Returns:
true if the array was previously non-empty