iicm.vrml.pwutils
Class IntArray

java.lang.Object
  extended by 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

Version:
0.1, latest change: 1 Okt 96
Author:
Michael Pichler, Karin Roschker, (based on Field macro by Gerald Pani)

Field Summary
private  int count_
           
private  int[] data_
           
 
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).
 
Method Summary
 void append(int d)
          append one int element
 boolean clearData()
          clear the array
private  void enlarge(int newsize)
          enlarge the data array to its new size; does not change count_
 int getCount()
          get count of used array members.
 int[] getData()
          get data array.
 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
 

Field Detail

data_

private int[] data_

count_

private int count_
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


append

public void append(int d)
append one int element


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

enlarge

private void enlarge(int newsize)
enlarge the data array to its new size; does not change count_