|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ivmaidns.util.DoubleVector
public final class DoubleVector
Class for 'double' array wrappers.
This class wraps a primitive double
-type array, and
has the possibility to resize (when required) the wrapped array.
This class supports cloning, serialization and comparison of its
instances. In addition, the class contains static
methods for double
arrays resizing, filling in,
reversing, vector arithmetics (addition, subtraction,
multiplication by a value, scalar multiplication, polynome
evaluation), elements summing and non-zero elements counting,
linear/binary searching in for a value or sequence,
natural/binary equality testing, mismatches counting,
'less-equal-greater' comparison, sorting, and 'to-string'
conversion.
ByteVector
,
CharVector
,
FloatVector
,
IntVector
,
LongVector
,
ShortVector
,
BooleanVector
,
ObjectVector
,
Serialized FormField Summary | |
---|---|
protected double[] |
array
The wrapped (encapsulated) custom double array. |
protected static double[] |
EMPTY
A constant initialized with an instance of empty double array. |
Constructor Summary | |
---|---|
DoubleVector()
Constructs an empty double vector. |
|
DoubleVector(double[] array)
Constructs a new double array wrapper. |
|
DoubleVector(int size)
Constructs a new double vector of the specified
length. |
Method Summary | |
---|---|
static void |
addTo(double[] arrayA,
double[] arrayB)
Adds a given vector (array) to another one. |
double[] |
array()
Returns array wrapped by this vector. |
static int |
binarySearch(double[] array,
int offset,
int len,
double value)
Searches (fast) for value in a given sorted array. |
java.lang.Object |
clone()
Creates and returns a copy of this object. |
static int |
compare(double[] arrayA,
int offsetA,
int lenA,
double[] arrayB,
int offsetB,
int lenB)
Compares two given array regions. |
void |
copyAt(int srcOffset,
int destOffset,
int len)
Copies a region of values at one offset to another offset in this vector. |
static int |
countNonZero(double[] array)
Count non-zero elements in a given array. |
static double[] |
ensureSize(double[] array,
int size)
Ensures the length (capacity) of a given array. |
void |
ensureSize(int size)
Ensures the size (capacity) of this vector. |
static boolean |
equals(double[] arrayA,
double[] arrayB)
Tests whether or not the specified two arrays are equal. |
boolean |
equals(java.lang.Object obj)
Indicates whether this object is equal to the
specified one. |
static void |
fill(double[] array,
int offset,
int len,
double value)
Fills in the region of a given array with the specified value. |
java.lang.Object |
getAt(int index)
Returns the wrapped value of the element at the specified index. |
double |
getDoubleAt(int index)
Returns value of the element at the specified index. |
boolean |
greaterThan(java.lang.Object obj)
Tests for being semantically greater than the argument. |
int |
hashCode()
Computes and returns a hash code value for the object. |
static int |
hashCode(double[] array)
Produces a hash code value for a given array. |
static int |
indexOf(double[] subArray,
int offset,
int len,
int index,
double[] array)
Searches forward for the specified sequence in a given array. |
static int |
indexOf(double value,
int index,
double[] array)
Searches forward for value in a given array. |
void |
integrityCheck()
Verifies this object for its integrity. |
static int |
lastIndexOf(double[] subArray,
int offset,
int len,
int index,
double[] array)
Searches backward for the specified sequence in a given array. |
static int |
lastIndexOf(double value,
int index,
double[] array)
Searches backward for value in a given array. |
int |
length()
Returns the number of elements in this vector. |
static boolean |
mathEquals(double[] arrayA,
double[] arrayB)
Tests whether or not the specified two arrays are mathematically equal. |
static int |
mismatches(double[] arrayA,
int offsetA,
double[] arrayB,
int offsetB,
int len)
Count the mismatches of two given array regions. |
static void |
multiplyBy(double[] array,
double value)
Multiplies a given vector (array) by a value. |
static double |
polynome(double value,
double[] array)
Computes the result of substitution of a given value into the polynome specified by its coefficients. |
static void |
quickSort(double[] array,
int offset,
int len)
Sorts the elements in the region of a given array using 'Quick' algorithm. |
static double[] |
resize(double[] array,
int size)
Resizes a given array. |
void |
resize(int size)
Resizes this vector. |
static void |
reverse(double[] array)
Reverses the elements order in a given array. |
static double |
scalarMul(double[] arrayA,
double[] arrayB)
Multiplies two given vectors (arrays) in a scalar way. |
void |
setArray(double[] array)
Sets another array to be wrapped by this vector. |
void |
setAt(int index,
double value)
Assigns a new value to the element at the specified index. |
static void |
subtractFrom(double[] arrayA,
double[] arrayB)
Subtracts a given vector (array) from another one. |
static double |
sumOf(double[] array,
int offset,
int len)
Sums the elements in the region of a given array. |
java.lang.String |
toString()
Converts this vector to its 'in-line' string
representation. |
static java.lang.String |
toString(double[] array,
int offset,
int len,
char separator)
Converts the region of a given array to its 'in-line' string representation. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final double[] EMPTY
double
array.
array
protected double[] array
double
array.
array must be non-null
.
EMPTY
,
DoubleVector()
,
DoubleVector(int)
,
DoubleVector(double[])
,
setArray(double[])
,
array()
,
length()
,
resize(int)
,
ensureSize(int)
,
setAt(int, double)
,
getDoubleAt(int)
,
copyAt(int, int, int)
,
clone()
,
integrityCheck()
Constructor Detail |
---|
public DoubleVector()
double
vector.
This constructor is used for the creation of a resizable vector.
The length of such a vector is changed only by
resize(int)
and ensureSize(int)
methods.
DoubleVector(int)
,
DoubleVector(double[])
,
array()
,
length()
,
resize(int)
,
ensureSize(int)
,
setAt(int, double)
,
getDoubleAt(int)
,
copyAt(int, int, int)
,
clone()
,
toString()
public DoubleVector(int size)
double
vector of the specified
length.
This constructor is typically used for the creation of a vector
with a fixed size. All elements of the created vector are set to
zero.
size
- the initial length (unsigned) of the vector to be created.
java.lang.OutOfMemoryError
- if there is not enough memory.DoubleVector()
,
DoubleVector(double[])
,
array()
,
length()
,
setAt(int, double)
,
getDoubleAt(int)
,
copyAt(int, int, int)
,
fill(double[], int, int, double)
,
clone()
,
toString()
public DoubleVector(double[] array) throws java.lang.NullPointerException
double
array wrapper.
This constructor is used for the creation of a vector which wraps
the specified array (without copying it). The wrapped array may
be further replaced with another one only by
setArray(double[])
and by resize(int)
,
ensureSize(int)
methods.
array
- the double
array (must be non-null
) to
be wrapped.
java.lang.NullPointerException
- if array is null
.DoubleVector()
,
DoubleVector(int)
,
setArray(double[])
,
array()
,
resize(int)
,
ensureSize(int)
,
setAt(int, double)
,
getDoubleAt(int)
,
copyAt(int, int, int)
,
clone()
,
toString()
Method Detail |
---|
public void setArray(double[] array) throws java.lang.NullPointerException
this
vector.
Important notes: resize(int)
and
ensureSize(int)
methods may change the array to be
wrapped too (but only with its copy of a different length); this
method does not copy array. If an exception is thrown
then this
vector remains unchanged.
array
- the double
array (must be non-null
) to
be wrapped.
java.lang.NullPointerException
- if array is null
.DoubleVector()
,
DoubleVector(double[])
,
array()
,
resize(int)
,
ensureSize(int)
,
setAt(int, double)
,
getDoubleAt(int)
,
copyAt(int, int, int)
,
clone()
public final double[] array()
this
vector.
Important notes: this method does not copy array.
double
array (not null
), which is
wrapped.DoubleVector(double[])
,
setArray(double[])
,
length()
,
resize(int)
,
ensureSize(int)
,
copyAt(int, int, int)
,
clone()
public int length()
this
vector.
The result is the same as length
of
array()
.
length
in interface Indexable
this
vector.setArray(double[])
,
array()
,
setAt(int, double)
,
resize(int)
,
ensureSize(int)
,
getDoubleAt(int)
,
getAt(int)
public java.lang.Object getAt(int index) throws java.lang.ArrayIndexOutOfBoundsException
new Double(array()[index])
.
getAt
in interface Indexable
index
- the index (must be in the range) at which to return an element.
Double
) at index.
java.lang.ArrayIndexOutOfBoundsException
- if index is negative or is not less than
length()
.
java.lang.OutOfMemoryError
- if there is not enough memory.getDoubleAt(int)
,
array()
,
length()
public final double getDoubleAt(int index) throws java.lang.ArrayIndexOutOfBoundsException
array()[index]
.
index
- the index (must be in the range) at which to return an element.
double
element at index.
java.lang.ArrayIndexOutOfBoundsException
- if index is negative or is not less than
length()
.array()
,
length()
,
setAt(int, double)
,
resize(int)
,
ensureSize(int)
public void setAt(int index, double value) throws java.lang.ArrayIndexOutOfBoundsException
this
vector remains
unchanged.
index
- the index (must be in the range) at which to assign a new value.value
- the value to be assigned.
java.lang.ArrayIndexOutOfBoundsException
- if index is negative or is not less than
length()
.setArray(double[])
,
array()
,
length()
,
getDoubleAt(int)
,
resize(int)
,
ensureSize(int)
,
copyAt(int, int, int)
,
fill(double[], int, int, double)
public void copyAt(int srcOffset, int destOffset, int len) throws java.lang.ArrayIndexOutOfBoundsException
this
vector.
Copying is performed here through
arraycopy(Object, int, Object, int, int)
method of
System
class. Negative len is treated as
zero. If an exception is thrown then this
vector
remains unchanged.
srcOffset
- the source first index (must be in the range) of the region to be
copied.destOffset
- the first index (must be in the range) of the region copy
destination.len
- the length of the region to be copied.
java.lang.ArrayIndexOutOfBoundsException
- if len is positive and (srcOffset is
negative or is greater than length()
minus
len, or destOffset is negative or is
greater than length()
minus len).array()
,
length()
,
setAt(int, double)
,
getDoubleAt(int)
,
resize(int)
,
ensureSize(int)
public void resize(int size)
this
vector.
The result is the same as of
setArray(resize(array(), size))
. This method changes
the length of this
vector to the specified one.
Important notes: if size (length) of the vector grows then its
new elements are set to zero. If an exception is thrown then
this
vector remains unchanged.
size
- the (unsigned) length of this
vector to set.
java.lang.OutOfMemoryError
- if there is not enough memory.DoubleVector(int)
,
setArray(double[])
,
array()
,
length()
,
ensureSize(int)
,
resize(double[], int)
public void ensureSize(int size)
this
vector.
The result is the same as of
setArray(ensureSize(array(), size))
. This method
changes (only if size is greater than
length()
) the length of this
vector to
a value not less than size. Important notes: if size
(length) of the vector grows then its new elements are set to
zero. If an exception is thrown then this
vector
remains unchanged.
size
- the (unsigned) length of this
vector to be ensured.
java.lang.OutOfMemoryError
- if there is not enough memory.array()
,
length()
,
setAt(int, double)
,
resize(int)
,
ensureSize(double[], int)
public static final double[] resize(double[] array, int size) throws java.lang.NullPointerException
length
of array is the same as
size then array is returned else
array content is copied into the result (all new
elements are set to zero).
array
- the array (must be non-null
) to be resized.size
- the (unsigned) length of the array to set.
null
, with
length
equal to size).
java.lang.NullPointerException
- if array is null
.
java.lang.OutOfMemoryError
- if there is not enough memory.resize(int)
,
ensureSize(double[], int)
,
fill(double[], int, int, double)
public static final double[] ensureSize(double[] array, int size) throws java.lang.NullPointerException
length
of array) the length of
array. Important notes: array elements are
not changed; if length
of array is
greater or the same as size then array is
returned else array content is copied into the result
(all new elements are set to zero).
array
- the array (must be non-null
) to be length-ensured.size
- the (unsigned) length of the array to ensure.
null
, with
length
not less than size).
java.lang.NullPointerException
- if array is null
.
java.lang.OutOfMemoryError
- if there is not enough memory.ensureSize(int)
,
resize(double[], int)
,
fill(double[], int, int, double)
public static final void fill(double[] array, int offset, int len, double value) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
arraycopy(Object, int, Object, int, int)
method of
System
class.
array
- the array (must be non-null
) to be filled in.offset
- the first index (must be in the range) of the region to fill in.len
- the length of the region to be filled.value
- the value to fill with.
java.lang.NullPointerException
- if array is null
.
java.lang.ArrayIndexOutOfBoundsException
- if len is positive and (offset is negative
or is greater than length
of array minus
len).array()
,
copyAt(int, int, int)
,
indexOf(double[], int, int, int, double[])
,
lastIndexOf(double[], int, int, int, double[])
,
toString(double[], int, int, char)
,
quickSort(double[], int, int)
,
binarySearch(double[], int, int, double)
public static final void reverse(double[] array) throws java.lang.NullPointerException
array
- the array (must be non-null
) to be reversed.
java.lang.NullPointerException
- if array is null
.array()
,
addTo(double[], double[])
,
subtractFrom(double[], double[])
,
countNonZero(double[])
,
indexOf(double, int, double[])
,
lastIndexOf(double, int, double[])
,
hashCode(double[])
,
equals(double[], double[])
,
compare(double[], int, int, double[], int, int)
,
mismatches(double[], int, double[], int, int)
public static final void addTo(double[] arrayA, double[] arrayB) throws java.lang.NullPointerException
arrayA
- the first array (must be non-null
) to be added to.arrayB
- the second array (must be non-null
) to add.
java.lang.NullPointerException
- if arrayA is null
or arrayB is
null
.array()
,
reverse(double[])
,
subtractFrom(double[], double[])
,
multiplyBy(double[], double)
,
sumOf(double[], int, int)
,
scalarMul(double[], double[])
,
polynome(double, double[])
,
mathEquals(double[], double[])
public static final void subtractFrom(double[] arrayA, double[] arrayB) throws java.lang.NullPointerException
arrayA
- the first array (must be non-null
) to be subtracted
from.arrayB
- the second array (must be non-null
) to subtract.
java.lang.NullPointerException
- if arrayA is null
or arrayB is
null
.array()
,
fill(double[], int, int, double)
,
reverse(double[])
,
addTo(double[], double[])
,
multiplyBy(double[], double)
,
sumOf(double[], int, int)
,
scalarMul(double[], double[])
,
polynome(double, double[])
,
mathEquals(double[], double[])
public static final void multiplyBy(double[] array, double value) throws java.lang.NullPointerException
array
- the array (must be non-null
) to be multiplied.value
- the value to multiply by.
java.lang.NullPointerException
- if array is null
.array()
,
fill(double[], int, int, double)
,
reverse(double[])
,
addTo(double[], double[])
,
subtractFrom(double[], double[])
,
sumOf(double[], int, int)
,
scalarMul(double[], double[])
,
polynome(double, double[])
,
countNonZero(double[])
,
mathEquals(double[], double[])
public static final double scalarMul(double[] arrayA, double[] arrayB) throws java.lang.NullPointerException
arrayA
- the first array (must be non-null
) to multiply.arrayB
- the second array (must be non-null
) to multiply.
java.lang.NullPointerException
- if arrayA is null
or arrayB is
null
.array()
,
addTo(double[], double[])
,
subtractFrom(double[], double[])
,
multiplyBy(double[], double)
,
sumOf(double[], int, int)
,
polynome(double, double[])
,
mathEquals(double[], double[])
,
mismatches(double[], int, double[], int, int)
public static final double polynome(double value, double[] array) throws java.lang.NullPointerException
sum(array[index] * power(value, index))
. If
length
of array is zero then
0
is returned.
value
- the value to be substituted.array
- the array (must be non-null
) of the polynome
coefficients, arranged by their weight.
java.lang.NullPointerException
- if array is null
.array()
,
addTo(double[], double[])
,
subtractFrom(double[], double[])
,
multiplyBy(double[], double)
,
scalarMul(double[], double[])
,
sumOf(double[], int, int)
,
countNonZero(double[])
,
mathEquals(double[], double[])
public static final double sumOf(double[] array, int offset, int len) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
array
- the array (must be non-null
) which elements to be
summed.offset
- the first index (must be in the range) of the region.len
- the length of the region.
java.lang.NullPointerException
- if array is null
.
java.lang.ArrayIndexOutOfBoundsException
- if len is positive and (offset is negative
or is greater than length
of array minus
len).array()
,
fill(double[], int, int, double)
,
addTo(double[], double[])
,
subtractFrom(double[], double[])
,
multiplyBy(double[], double)
,
countNonZero(double[])
,
mathEquals(double[], double[])
,
mismatches(double[], int, double[], int, int)
,
scalarMul(double[], double[])
,
polynome(double, double[])
public static final int countNonZero(double[] array) throws java.lang.NullPointerException
array
- the array (must be non-null
) to count non-zero
elements in.
length
of array) of non-zero elements.
java.lang.NullPointerException
- if array is null
.array()
,
fill(double[], int, int, double)
,
sumOf(double[], int, int)
,
scalarMul(double[], double[])
,
polynome(double, double[])
,
mathEquals(double[], double[])
,
compare(double[], int, int, double[], int, int)
,
mismatches(double[], int, double[], int, int)
public static final int indexOf(double value, int index, double[] array) throws java.lang.NullPointerException
length
of
array. If value is not found then the
result is -1
. Important notes: any two values are
treated as equal if and only if their binary representations are
equal.
value
- the value to sequentially search for.index
- the first index, from which to begin forward searching.array
- the array (must be non-null
) to be searched in.
-1
(if not found).
java.lang.NullPointerException
- if array is null
.array()
,
lastIndexOf(double, int, double[])
,
indexOf(double[], int, int, int, double[])
,
binarySearch(double[], int, int, double)
,
equals(double[], double[])
,
compare(double[], int, int, double[], int, int)
public static final int lastIndexOf(double value, int index, double[] array) throws java.lang.NullPointerException
-1
, too big
index is treated as length
of
array minus one. If value is not found then
the result is -1
. Important notes: any two values
are treated as equal if and only if their binary representations
are equal.
value
- the value to sequentially search for.index
- the first index, from which to begin backward searching.array
- the array (must be non-null
) to be searched in.
-1
(if not found).
java.lang.NullPointerException
- if array is null
.array()
,
indexOf(double, int, double[])
,
lastIndexOf(double[], int, int, int, double[])
,
binarySearch(double[], int, int, double)
,
reverse(double[])
,
equals(double[], double[])
,
compare(double[], int, int, double[], int, int)
public static final int indexOf(double[] subArray, int offset, int len, int index, double[] array) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
length
of array. If the
sequence is not found then the result is -1
.
Important notes: any two elements are treated as equal if and
only if their binary representations are equal.
subArray
- the array (must be non-null
) specifying the sequence
of values to search for.offset
- the offset (must be in the range) of the sequence in
subArray.len
- the length of the sequence.index
- the first index, from which to begin forward searching.array
- the array (must be non-null
) to be searched in.
-1
(if not found).
java.lang.NullPointerException
- if subArray is null
or array
is null
.
java.lang.ArrayIndexOutOfBoundsException
- if len is positive and (offset is negative
or is greater than length
of subArray
minus len).array()
,
indexOf(double, int, double[])
,
lastIndexOf(double[], int, int, int, double[])
,
equals(double[], double[])
,
compare(double[], int, int, double[], int, int)
public static final int lastIndexOf(double[] subArray, int offset, int len, int index, double[] array) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
-1
, too big
index is treated as length
of
array minus one. If the sequence is not found then the
result is -1
. Important notes: any two elements are
treated as equal if and only if their binary representations are
equal.
subArray
- the array (must be non-null
) specifying the sequence
of values to search for.offset
- the offset (must be in the range) of the sequence in
subArray.len
- the length of the sequence.index
- the first index, from which to begin backward searching.array
- the array (must be non-null
) to be searched in.
-1
(if not found).
java.lang.NullPointerException
- if subArray is null
or array
is null
.
java.lang.ArrayIndexOutOfBoundsException
- if len is positive and (offset is negative
or is greater than length
of subArray
minus len).array()
,
lastIndexOf(double, int, double[])
,
indexOf(double[], int, int, int, double[])
,
equals(double[], double[])
,
compare(double[], int, int, double[], int, int)
public static final java.lang.String toString(double[] array, int offset, int len, char separator) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
double
values (of the
specified region of array) are placed into the
resulting string in the direct index order, delimited by a single
separator character. Negative len is
treated as zero.
array
- the array (must be non-null
) to be converted.offset
- the first index (must be in the range) of the region to be
converted.len
- the length of the region to be converted.separator
- the delimiter character.
null
) of the
specified region.
java.lang.NullPointerException
- if array is null
.
java.lang.ArrayIndexOutOfBoundsException
- if len is positive and (offset is negative
or is greater than length
of array minus
len).
java.lang.OutOfMemoryError
- if there is not enough memory.array()
,
toString()
,
fill(double[], int, int, double)
,
quickSort(double[], int, int)
,
binarySearch(double[], int, int, double)
public static final int hashCode(double[] array) throws java.lang.NullPointerException
array
- the array (must be non-null
) to evaluate hash of.
java.lang.NullPointerException
- if array is null
.array()
,
hashCode()
,
fill(double[], int, int, double)
,
reverse(double[])
,
sumOf(double[], int, int)
,
countNonZero(double[])
,
indexOf(double, int, double[])
,
lastIndexOf(double, int, double[])
,
equals(double[], double[])
,
compare(double[], int, int, double[], int, int)
,
mismatches(double[], int, double[], int, int)
public static final boolean mathEquals(double[] arrayA, double[] arrayB) throws java.lang.NullPointerException
true
if and only if both of the
arrays are of the same length and all the elements of the first
array are naturally equal to the corresponding elements of the
second array.
arrayA
- the first array (must be non-null
) to be compared.arrayB
- the second array (must be non-null
) to compare with.
true
if and only if arrayA content is the
same as arrayB content.
java.lang.NullPointerException
- if arrayA is null
or arrayB is
null
.array()
,
subtractFrom(double[], double[])
,
scalarMul(double[], double[])
,
sumOf(double[], int, int)
,
countNonZero(double[])
,
indexOf(double, int, double[])
,
lastIndexOf(double, int, double[])
,
equals(double[], double[])
,
compare(double[], int, int, double[], int, int)
,
mismatches(double[], int, double[], int, int)
public static final boolean equals(double[] arrayA, double[] arrayB) throws java.lang.NullPointerException
true
if and only if both of the
arrays are of the same length and all the elements of the first
array are equal to the corresponding elements of the second
array. Important notes: any two elements are treated as equal if
and only if their binary representations are equal.
arrayA
- the first array (must be non-null
) to be compared.arrayB
- the second array (must be non-null
) to compare with.
true
if and only if arrayA content is the
same as arrayB content.
java.lang.NullPointerException
- if arrayA is null
or arrayB is
null
.array()
,
mathEquals(double[], double[])
,
equals(java.lang.Object)
,
fill(double[], int, int, double)
,
reverse(double[])
,
indexOf(double, int, double[])
,
lastIndexOf(double, int, double[])
,
hashCode(double[])
,
compare(double[], int, int, double[], int, int)
,
mismatches(double[], int, double[], int, int)
public static final int mismatches(double[] arrayA, int offsetA, double[] arrayB, int offsetB, int len) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
arrayA
- the first array (must be non-null
) to be compared.offsetA
- the first index (must be in the range) of the first region.arrayB
- the second array (must be non-null
) to compare with.offsetB
- the first index (must be in the range) of the second region.len
- the length of the regions.
java.lang.NullPointerException
- if arrayA is null
or arrayB is
null
.
java.lang.ArrayIndexOutOfBoundsException
- if len is positive and (offsetA is negative
or is greater than length
of arrayA minus
len, or offsetB is negative or is greater
than length
of arrayB minus
len).array()
,
fill(double[], int, int, double)
,
reverse(double[])
,
subtractFrom(double[], double[])
,
scalarMul(double[], double[])
,
sumOf(double[], int, int)
,
countNonZero(double[])
,
hashCode(double[])
,
mathEquals(double[], double[])
,
equals(double[], double[])
,
compare(double[], int, int, double[], int, int)
public static final int compare(double[] arrayA, int offsetA, int lenA, double[] arrayB, int offsetB, int lenB) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
double
values (the absolute value of the result,
in fact, is the distance between the first found mismatch and the
end of the bigger-length region). Negative lenA is
treated as zero. Negative lenB is treated as zero.
Important notes: the content of array regions is compared before
comparing their length; any two double
values are
compared in the natural way, except for 0
(which is
also greater than -0
) and for NaN
(which is greater than any non-NaN
).
arrayA
- the first array (must be non-null
) to be compared.offsetA
- the first index (must be in the range) of the first region.lenA
- the length of the first region.arrayB
- the second array (must be non-null
) to compare with.offsetB
- the first index (must be in the range) of the second region.lenB
- the length of the second region.
java.lang.NullPointerException
- if arrayA is null
or arrayB is
null
.
java.lang.ArrayIndexOutOfBoundsException
- if lenA is positive and (offsetA is
negative or is greater than length
of
arrayA minus lenA), or if lenB
is positive and (offsetB is negative or is greater
than length
of arrayB minus
lenB).array()
,
greaterThan(java.lang.Object)
,
fill(double[], int, int, double)
,
reverse(double[])
,
sumOf(double[], int, int)
,
indexOf(double, int, double[])
,
lastIndexOf(double, int, double[])
,
hashCode(double[])
,
mathEquals(double[], double[])
,
equals(double[], double[])
,
mismatches(double[], int, double[], int, int)
public static final void quickSort(double[] array, int offset, int len) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
O(log(len) * len)
typically, but may be of
O(len * len)
in the worst case (which is rare, in
fact). Negative len is treated as zero. If an
exception is thrown then array remains unchanged. Else
the region content is altered. Important notes: values comparison
is performed in the natural way, except for 0
(which
is also greater than -0
) and for NaN
(which is greater than any non-NaN
).
array
- the array (must be non-null
) to be sorted.offset
- the first index (must be in the range) of the region to sort.len
- the length of the region to sort.
java.lang.NullPointerException
- if array is null
.
java.lang.ArrayIndexOutOfBoundsException
- if len is positive and (offset is negative
or is greater than length
of array minus
len).
java.lang.OutOfMemoryError
- if there is not enough memory.array()
,
binarySearch(double[], int, int, double)
,
compare(double[], int, int, double[], int, int)
,
fill(double[], int, int, double)
,
toString(double[], int, int, char)
public static final int binarySearch(double[] array, int offset, int len, double value) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
O(log(len))
. Negative len is treated as
zero. If value is not found then
(-result - 1)
is the offset of the insertion point
for value. Important notes: values comparison is
performed in the natural way, except for 0
(which is
also greater than -0
) and for NaN
(which is greater than any non-NaN
).
array
- the sorted array (must be non-null
) to be searched
in.offset
- the first index (must be in the range) of the region to search
in.len
- the length of the region to search in.value
- the value to search for.
(-insertionOffset - 1)
(a negative integer) if not
found.
java.lang.NullPointerException
- if array is null
.
java.lang.ArrayIndexOutOfBoundsException
- if len is positive and (offset is negative
or is greater than length
of array minus
len).array()
,
indexOf(double, int, double[])
,
lastIndexOf(double, int, double[])
,
quickSort(double[], int, int)
,
compare(double[], int, int, double[], int, int)
,
fill(double[], int, int, double)
,
toString(double[], int, int, char)
public java.lang.Object clone()
this
object.
This method creates a new instance of the class of this object
and initializes its array with a copy of
array of this
vector.
clone
in interface ReallyCloneable
clone
in class java.lang.Object
null
and != this
) of
this
instance.
java.lang.OutOfMemoryError
- if there is not enough memory.DoubleVector()
,
array()
,
getDoubleAt(int)
,
equals(java.lang.Object)
public int hashCode()
this
vector to
produce a single hash code value.
hashCode
in class java.lang.Object
this
object.hashCode(double[])
,
array()
,
length()
,
getDoubleAt(int)
,
equals(java.lang.Object)
public boolean equals(java.lang.Object obj)
this
object is equal to the
specified one.
This method returns true
if and only if
obj is instance of this vector class and all elements
of this
vector are equal to the corresponding
elements of obj vector. Important notes: any two
elements are treated as equal if and only if their binary
representations are equal.
equals
in class java.lang.Object
obj
- the object (may be null
) with which to compare.
true
if and only if this
value is the
same as obj value.DoubleVector()
,
equals(double[], double[])
,
mathEquals(double[], double[])
,
array()
,
length()
,
getDoubleAt(int)
,
hashCode()
,
greaterThan(java.lang.Object)
public boolean greaterThan(java.lang.Object obj)
true
if and only if obj is
instance of this
class and this
object
is greater than the specified object. Vectors are compared in the
element-by-element manner, starting at index 0
.
Important notes: any two double
values are compared
in the natural way, except for 0
(which is also
greater than -0
) and for NaN
(which is
greater than any non-NaN
).
greaterThan
in interface Sortable
obj
- the second compared object (may be null
).
true
if obj is comparable with
this
and this
object is greater than
obj, else false
.compare(double[], int, int, double[], int, int)
,
array()
,
length()
,
getDoubleAt(int)
,
equals(java.lang.Object)
public java.lang.String toString()
this
vector to its 'in-line' string
representation.
The string representations of double
values of the
wrapped array are placed into the resulting string in
the direct index order, delimited by a single space.
toString
in class java.lang.Object
null
) of
this
object.
java.lang.OutOfMemoryError
- if there is not enough memory.toString(double[], int, int, char)
,
array()
,
length()
public void integrityCheck()
this
object for its integrity.
For debug purpose only.
integrityCheck
in interface Verifiable
java.lang.InternalError
- if integrity violation is detected.DoubleVector(double[])
,
setArray(double[])
,
array()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |