com.graphbuilder.curve
Class ValueVector

java.lang.Object
  extended bycom.graphbuilder.curve.ValueVector

public class ValueVector
extends java.lang.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
protected  int size
           
protected  double[] value
           
 
Constructor Summary
ValueVector()
          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
 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 size()
          Returns the number of values in the value array.
 void trimArray()
          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 Detail

size

protected int size

value

protected double[] value
Constructor Detail

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:
java.lang.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 Detail

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:
java.lang.IllegalArgumentException - If index < 0 or index >= size.

set

public void set(double d,
                int index)
Sets the value at the specified index.

Throws:
java.lang.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:
java.lang.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:
java.lang.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.