public class ValueVector extends Object
Modifier and Type | Field and Description |
---|---|
protected int |
size |
protected double[] |
value |
Constructor and Description |
---|
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.
|
Modifier and Type | Method and 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 |
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.
|
public ValueVector()
public ValueVector(double[] value, int size)
IllegalArgumentException
- If the value array is null or size < 0 or size > data.length.public ValueVector(int initialCapacity)
public int size()
public double get(int index)
IllegalArgumentException
- If index < 0 or index >= size.public void set(double d, int index)
IllegalArgumentException
- If index < 0 or index >= size.public void remove(int index)
IllegalArgumentException
- If index < 0 or index >= size.public void add(double d)
public void insert(double d, int index)
IllegalArgumentException
- If index < 0 or index > size.public void ensureCapacity(int capacity)
public void trimArray()
Copyright © 2024. All rights reserved.