|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectAbstractCollection<E>
AbstractList<Number>
Vector
public abstract class Vector
A vector of real numbers. An instance of Vector can be a wrapper around an
array of Java primitive type (typically float[] or double[]), or it
may be a function calculating values on the fly. Often the two above-cited cases are
used together, for example in a time series where:
Instances of Vector are created by calls to the create(Object) static method.
The supplied array is not cloned - changes to the primitive array are reflected in the vector,
and vis-versa.
Vectors can be created over a subrange of an array, provides a view of the elements in reverse order, etc. The example below creates a view over a subrange:
Vector v = Vector.create(array).subList(lower, upper)
| utility/geotk-utility (download) | View source code for this class |
| Field Summary |
|---|
| Fields inherited from class AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
protected |
Vector()
For subclasses constructor. |
| Method Summary | |
|---|---|
abstract byte |
byteValue(int index)
Returns the value at the given index as a byte. |
Vector |
concatenate(Vector toAppend)
Returns the concatenation of this vector with the given one. |
static Vector |
create(Object array)
Wraps the given object in a vector. |
static Vector |
createSequence(double first,
double increment,
int length)
Creates a sequence of numbers in a given range of values using the given increment. |
abstract double |
doubleValue(int index)
Returns the value at the given index as a double. |
abstract float |
floatValue(int index)
Returns the value at the given index as a float. |
abstract Number |
get(int index)
Returns the number at the given index, or null if none. |
abstract Class<? extends Number> |
getElementType()
Returns the type of elements in this vector. |
abstract int |
intValue(int index)
Returns the value at the given index as an int. |
abstract boolean |
isNaN(int index)
Returns true if the value at the given index is NaN. |
abstract long |
longValue(int index)
Returns the value at the given index as a long. |
Vector |
reverse()
Returns a view which contains the values of this vector in reverse order. |
abstract Number |
set(int index,
Number value)
Sets the number at the given index. |
abstract short |
shortValue(int index)
Returns the value at the given index as a short. |
abstract int |
size()
Returns the number of elements in this vector. |
Vector |
subList(int lower,
int upper)
Returns a view which contain the values of this vector in the given index range. |
Vector |
subList(int first,
int step,
int length)
Returns a view which contain the values of this vector in a given index range. |
Vector |
view(int... index)
Returns a view which contains the values of this vector at the given indexes. |
| Methods inherited from class AbstractList |
|---|
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange |
| Methods inherited from class AbstractCollection |
|---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface Collection |
|---|
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, toArray, toArray |
| Methods inherited from interface List |
|---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
| Constructor Detail |
|---|
protected Vector()
| Method Detail |
|---|
public static Vector create(Object array)
throws IllegalArgumentException
float[].Float[].Vector, in which case it is returned unchanged.null value, in which case null is returned.The argument is not cloned. Consequently changes in the underlying array are reflected in this vector, and vis-versa.
array - The object to wrap in a vector, or null.
null if the argument was null.
IllegalArgumentException - If the type of the given object is not recognized by the method.
public static Vector createSequence(double first,
double increment,
int length)
first inclusive to (first + increment*length)
exclusive. Note that the value given by the first argument is equivalent to a
"lowest" or "minimum" value only if the given increment is positive.
The element type will be the smallest type that can be
used for storing every values. For example it will be Byte.class for the range
[100:1:120] but will be Double.class for the range [0:0.1:1].
first - The first value, inclusive.increment - The difference between the values at two adjacent indexes.length - The length of the desired vector.
public abstract int size()
size in interface Collection<Number>size in interface List<Number>size in class AbstractCollection<Number>public abstract Class<? extends Number> getElementType()
float[], then
this method returns Float.class, not Float.TYPE.
getElementType in interface CheckedCollection<Number>getElementType in interface CheckedContainer<Number>
public abstract boolean isNaN(int index)
throws IndexOutOfBoundsException
true if the value at the given index is NaN.
index - The index in the [0 … size-1] range.
true if the value at the given index is NaN.
IndexOutOfBoundsException - if the given index is out of bounds.
public abstract double doubleValue(int index)
throws IndexOutOfBoundsException,
ClassCastException
double.
index - The index in the [0 … size-1] range.
IndexOutOfBoundsException - if the given index is out of bounds.
ClassCastException - if the component type can not be converted to a
double by an identity or widening conversion.
public abstract float floatValue(int index)
throws IndexOutOfBoundsException,
ClassCastException
float.
If this vector uses internally a wider type like double, then this method may
cast the value or throw an exception at implementation choice. The general guidelines
are:
create(Object), throw an exception because we assume
that the data provider thinks that the extra precision is needed.createSequence(double, double, int)), cast the value because the calculation accuracy is
often unknown to the vector - and not necessarily its job.
For safety users should either call doubleValue(int) in all cases, or call this
methods only if the type returned by getElementType() has been verified.
index - The index in the [0 … size-1] range.
IndexOutOfBoundsException - if the given index is out of bounds.
ClassCastException - if the component type can not be converted to a
float by an identity or widening conversion.
public abstract long longValue(int index)
throws IndexOutOfBoundsException,
ClassCastException
long.
If this vector uses internally a wider type, then this method may cast the value
or throw an exception according the same guidelines than floatValue(int).
index - The index in the [0 … size-1] range.
IndexOutOfBoundsException - if the given index is out of bounds.
ClassCastException - if the component type can not be converted to a
long by an identity or widening conversion.
public abstract int intValue(int index)
throws IndexOutOfBoundsException,
ClassCastException
int.
If this vector uses internally a wider type, then this method may cast the value
or throw an exception according the same guidelines than floatValue(int).
index - The index in the [0 … size-1] range.
IndexOutOfBoundsException - if the given index is out of bounds.
ClassCastException - if the component type can not be converted to an
int by an identity or widening conversion.
public abstract short shortValue(int index)
throws IndexOutOfBoundsException,
ClassCastException
short.
If this vector uses internally a wider type, then this method may cast the value
or throw an exception according the same guidelines than floatValue(int).
index - The index in the [0 … size-1] range.
IndexOutOfBoundsException - if the given index is out of bounds.
ClassCastException - if the component type can not be converted to a
short by an identity or widening conversion.
public abstract byte byteValue(int index)
throws IndexOutOfBoundsException,
ClassCastException
byte.
If this vector uses internally a wider type, then this method may cast the value
or throw an exception according the same guidelines than floatValue(int).
index - The index in the [0 … size-1] range.
IndexOutOfBoundsException - if the given index is out of bounds.
ClassCastException - if the component type can not be converted to a
byte by an identity or widening conversion.
public abstract Number get(int index)
throws IndexOutOfBoundsException
null if none.
get in interface List<Number>get in class AbstractList<Number>index - The index in the [0 … size-1] range.
IndexOutOfBoundsException - if the given index is out of bounds.
public abstract Number set(int index,
Number value)
throws IndexOutOfBoundsException,
ArrayStoreException
set in interface List<Number>set in class AbstractList<Number>index - The index in the [0 … size-1] range.value - The value to set at the given index.
IndexOutOfBoundsException - if the given index is out of bounds.
ArrayStoreException - if the given value can not be stored in this vector.
public Vector view(int... index)
throws IndexOutOfBoundsException
The indexes don't need to be in any particular order. The same index can be repeated more than once. Thus it is possible to create a vector larger than the original vector.
index - Index of the values to be returned.
IndexOutOfBoundsException - if at least one index is out of bounds.public final Vector reverse()
subList(size-1, -1,
size). It is declared final in order to force every
subclasses to override the later method instead than this one.
public final Vector subList(int lower,
int upper)
throws IndexOutOfBoundsException
lower inclusive to
upper exclusive.
This method delegates its work to subList(lower,
1, upper-lower). It is declared final in order to force every subclasses to override
the later method instead than this one.
subList in interface List<Number>subList in class AbstractList<Number>lower - Index of the first value to be included in the returned view.upper - Index after the last value to be included in the returned view.
IndexOutOfBoundsException - If an index is outside the
[0 … size-1] range.
public Vector subList(int first,
int step,
int length)
throws IndexOutOfBoundsException
first inclusive to
(first + step*length) exclusive with index incremented by the given step
value, which can be negative. More specifically the index i in the returned
vector will maps the element at index (first + step*i) in this
vector.
This method does not copy the values. Consequently any modification to the values of this vector will be reflected in the returned view and vis-versa.
first - Index of the first value to be included in the returned view.step - The index increment in this vector between two consecutive values
in the returned vector. Can be positive, zero or negative.length - The length of the vector to be returned. Can not be greater than
the length of this vector, except if the step is zero.
IndexOutOfBoundsException - If first or first + step*(length-1)
is outside the [0 … size-1] range.public Vector concatenate(Vector toAppend)
toAppend - The vector to concatenate at the end of this vector.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||