Class GrowableArray

java.lang.Object
cnuphys.splot.pdata.GrowableArray
Direct Known Subclasses:
DataColumn

public class GrowableArray extends Object
This class supports named arrays that grow. They are an alternative to Vectors or ArrayLists. The advantages are speed and usage for those cases where arrays are more convenient. Clients only have access to minimal copies which can be used as "just the right size" arrays.
Author:
heddle
  • Field Summary Link icon

    Fields
    Modifier and Type
    Field
    Description
    protected double[]
     
    protected int
     
    protected int
     
    protected int
     
    protected double
     
    protected double
     
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
    Creates a GrowableArray with initial capacity 100 and increment 100.
    GrowableArray(int initCap, int increment)
    Create a GrowableArray
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    void
    add(double val)
    Add a value to the array, growing it if necessary.
    void
    Reset the data array to the initial capacity and fill with all NaNs.
    double
    get(int index)
    Get the value at the given index
    double
    Get the maximum data value
    double[]
    Get the minimal copy of the data array.
    double
    Get the minimum data value
    void
    removes the first entry and moves all other entries up one
    void
    set(int index, double val)
    Set the value at the given index
    int
    Get the number of real data in the array, which in general is less than the length of the array.

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details Link icon

    • _data Link icon

      protected double[] _data
    • _dataLen Link icon

      protected int _dataLen
    • _increment Link icon

      protected int _increment
    • _initCap Link icon

      protected int _initCap
    • _minValue Link icon

      protected double _minValue
    • _maxValue Link icon

      protected double _maxValue
  • Constructor Details Link icon

    • GrowableArray Link icon

      public GrowableArray()
      Creates a GrowableArray with initial capacity 100 and increment 100.
    • GrowableArray Link icon

      public GrowableArray(int initCap, int increment)
      Create a GrowableArray
      Parameters:
      initCap - the initial capacity
      increment - the increment when the array grows.
  • Method Details Link icon

    • size Link icon

      public int size()
      Get the number of real data in the array, which in general is less than the length of the array. This is the effective length of the array, so loops should go from 0 to this value minus 1.
      Returns:
      the number of real data.
    • getMinimalCopy Link icon

      public double[] getMinimalCopy()
      Get the minimal copy of the data array. This copies the actual data into a new array of just the right size. This new array can be used normally, i.e., it is safe to use its length.
      Returns:
      a copy of the data array of just the right length
    • removeFirst Link icon

      public void removeFirst()
      removes the first entry and moves all other entries up one
    • add Link icon

      public void add(double val)
      Add a value to the array, growing it if necessary.
      Parameters:
      val - the value to add
    • getMinValue Link icon

      public double getMinValue()
      Get the minimum data value
      Returns:
      the minimum data value
    • getMaxValue Link icon

      public double getMaxValue()
      Get the maximum data value
      Returns:
      the maximum data value
    • clear Link icon

      public void clear()
      Reset the data array to the initial capacity and fill with all NaNs.
    • get Link icon

      public double get(int index)
      Get the value at the given index
      Parameters:
      index - the index
      Returns:
      the value at the index
    • set Link icon

      public void set(int index, double val)
      Set the value at the given index
      Parameters:
      index - the index
      val - the value at the index