iicm.vrml.pwutils
Class CharArray

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

public class CharArray
extends java.lang.Object

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


Constructor Summary
CharArray()
          create with default length
CharArray(char[] dat)
          copy initial data from another char[].
CharArray(CharArray dat)
          copy initial data from another CharArray (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*
CharArray(int len)
          create with initial buffer length
 
Method Summary
 void append(char d)
          append one char element
 void append(char[] d, int num)
          append several char elements
 boolean clearData()
          clear the array
 int getCount()
          get count of used array members.
 char[] getData()
          get data array.
 char[] getTrimmedArray()
          get data array with proper length.
 void setData(char[] dat)
          copy data from a char[]
 void setData(char[] dat, int n)
          copy first n elements of a char[]
 void setData(CharArray dat)
          copy data from another CharArray
 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

CharArray

public CharArray()
create with default length

CharArray

public CharArray(int len)
create with initial buffer length

CharArray

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

CharArray

public CharArray(CharArray dat)
copy initial data from another CharArray (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(CharArray dat)
copy data from another CharArray

setData

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

setData

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

getCount

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

getData

public final char[] 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 char[] getTrimmedArray()
get data array with proper length. May involve copying

append

public void append(char d)
append one char element

append

public void append(char[] d,
                   int num)
append several char 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