Class ValueVector

java.lang.Object
com.graphbuilder.curve.ValueVector

public class ValueVector extends Object
A value-vector is a sequence of values that some curves use to define themselves, sometimes called a knot-vector or a weight-vector. The values are stored using an array.
  • Field Summary

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

    Constructors
    Constructor
    Description
    Creates a ValueVector with initial capacity of 2.
    ValueVector(double[] value, int size)
    Creates a ValueVector using the specified array and initial size.
    ValueVector(int initialCapacity)
    Creates a ValueVector with the specified initial capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(double d)
    Adds a value to the value array at index location size.
    void
    ensureCapacity(int capacity)
    Checks that the value array has the specified capacity, otherwise the capacity of the value array is increased to be the maximum between twice the current capacity and the specified capacity.
    double
    get(int index)
    Returns the value at the specified index.
    void
    insert(double d, int index)
    Inserts the value at the specified index location.
    void
    remove(int index)
    Removes the value at the specified index.
    void
    set(double d, int index)
    Sets the value at the specified index.
    int
    Returns the number of values in the value array.
    void
    Creates a new value array of exact size, copying the values from the old array into the new one.

    Methods inherited from class java.lang.Object

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

    • size

      protected int size
    • value

      protected double[] value
  • Constructor Details

    • ValueVector

      public ValueVector()
      Creates a ValueVector with initial capacity of 2.
    • ValueVector

      public ValueVector(double[] value, int size)
      Creates a ValueVector using the specified array and initial size.
      Throws:
      IllegalArgumentException - If the value array is null or size < 0 or size > data.length.
    • ValueVector

      public ValueVector(int initialCapacity)
      Creates a ValueVector with the specified initial capacity.
  • Method Details

    • size

      public int size()
      Returns the number of values in the value array.
    • get

      public double get(int index)
      Returns the value at the specified index.
      Throws:
      IllegalArgumentException - If index < 0 or index >= size.
    • set

      public void set(double d, int index)
      Sets the value at the specified index.
      Throws:
      IllegalArgumentException - If index < 0 or index >= size.
    • remove

      public void remove(int index)
      Removes the value at the specified index. Values at a higher index are shifted to fill the space.
      Throws:
      IllegalArgumentException - If index < 0 or index >= size.
    • add

      public void add(double d)
      Adds a value to the value array at index location size.
    • insert

      public void insert(double d, int index)
      Inserts the value at the specified index location. Values at an equal or higher index are shifted to make space.
      Throws:
      IllegalArgumentException - If index < 0 or index > size.
    • ensureCapacity

      public void ensureCapacity(int capacity)
      Checks that the value array has the specified capacity, otherwise the capacity of the value array is increased to be the maximum between twice the current capacity and the specified capacity.
    • trimArray

      public void trimArray()
      Creates a new value array of exact size, copying the values from the old array into the new one.