|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ivmaidns.util.ShortVector
public final class ShortVector
Class for 'short' array wrappers.
This class wraps a primitive short
-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 short
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, mismatches
counting, signed/unsigned 'less-equal-greater' comparison,
sorting, and 'to-string' conversion.
ByteVector
,
CharVector
,
DoubleVector
,
FloatVector
,
IntVector
,
LongVector
,
BooleanVector
,
ObjectVector
,
UnsignedInt
,
Serialized FormField Summary | |
---|---|
protected short[] |
array
The wrapped (encapsulated) custom short array. |
protected static short[] |
EMPTY
A constant initialized with an instance of empty short array. |
Constructor Summary | |
---|---|
ShortVector()
Constructs an empty short vector. |
|
ShortVector(int size)
Constructs a new short vector of the specified
length. |
|
ShortVector(short[] array)
Constructs a new short array wrapper. |
Method Summary | |
---|---|
static void |
addTo(short[] arrayA,
short[] arrayB)
Adds a given vector (array) to another one. |
short[] |
array()
Returns array wrapped by this vector. |
static int |
binarySearch(short[] array,
int offset,
int len,
short value,
boolean isUnsigned)
Searches (fast) for value in a given sorted array. |
java.lang.Object |
clone()
Creates and returns a copy of this object. |
static int |
compare(short[] arrayA,
int offsetA,
int lenA,
short[] arrayB,
int offsetB,
int lenB,
boolean isUnsigned)
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 void |
counterSort(short[] array,
int offset,
int len,
boolean isUnsigned)
Sorts the elements in the region of a given array by counting the amount of each possible value in it. |
static int |
countNonZero(short[] array)
Count non-zero elements in a given array. |
void |
ensureSize(int size)
Ensures the size (capacity) of this vector. |
static short[] |
ensureSize(short[] array,
int size)
Ensures the length (capacity) of a given array. |
boolean |
equals(java.lang.Object obj)
Indicates whether this object is equal to the
specified one. |
static boolean |
equals(short[] arrayA,
short[] arrayB)
Tests whether or not the specified two arrays are equal. |
static void |
fill(short[] array,
int offset,
int len,
short 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. |
short |
getShortAt(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(short[] array)
Produces a hash code value for a given array. |
static int |
indexOf(short[] subArray,
int offset,
int len,
int index,
short[] array)
Searches forward for the specified sequence in a given array. |
static int |
indexOf(short value,
int index,
short[] array)
Searches forward for value in a given array. |
void |
integrityCheck()
Verifies this object for its integrity. |
static int |
lastIndexOf(short[] subArray,
int offset,
int len,
int index,
short[] array)
Searches backward for the specified sequence in a given array. |
static int |
lastIndexOf(short value,
int index,
short[] array)
Searches backward for value in a given array. |
int |
length()
Returns the number of elements in this vector. |
static int |
mismatches(short[] arrayA,
int offsetA,
short[] arrayB,
int offsetB,
int len)
Count the mismatches of two given array regions. |
static void |
multiplyBy(short[] array,
short value)
Multiplies a given vector (array) by a value. |
static int |
polynome(int intValue,
short[] array,
boolean isUnsigned)
Computes the result of substitution of a given int
value into the polynome specified by its coefficients. |
static void |
quickSort(short[] array,
int offset,
int len,
boolean isUnsigned)
Sorts the elements in the region of a given array using 'Quick' algorithm. |
void |
resize(int size)
Resizes this vector. |
static short[] |
resize(short[] array,
int size)
Resizes a given array. |
static void |
reverse(short[] array)
Reverses the elements order in a given array. |
static int |
scalarMul(short[] arrayA,
short[] arrayB,
boolean isUnsigned)
Multiplies two given vectors (arrays) in a scalar way. |
void |
setArray(short[] array)
Sets another array to be wrapped by this vector. |
void |
setAt(int index,
short value)
Assigns a new value to the element at the specified index. |
static void |
subtractFrom(short[] arrayA,
short[] arrayB)
Subtracts a given vector (array) from another one. |
static int |
sumOf(short[] array,
int offset,
int len,
boolean isUnsigned)
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(short[] array,
int offset,
int len,
char separator,
boolean isUnsigned)
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 short[] EMPTY
short
array.
array
protected short[] array
short
array.
array must be non-null
.
EMPTY
,
ShortVector()
,
ShortVector(int)
,
ShortVector(short[])
,
setArray(short[])
,
array()
,
length()
,
resize(int)
,
ensureSize(int)
,
setAt(int, short)
,
getShortAt(int)
,
copyAt(int, int, int)
,
clone()
,
integrityCheck()
Constructor Detail |
---|
public ShortVector()
short
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.
ShortVector(int)
,
ShortVector(short[])
,
array()
,
length()
,
resize(int)
,
ensureSize(int)
,
setAt(int, short)
,
getShortAt(int)
,
copyAt(int, int, int)
,
clone()
,
toString()
public ShortVector(int size)
short
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.ShortVector()
,
ShortVector(short[])
,
array()
,
length()
,
setAt(int, short)
,
getShortAt(int)
,
copyAt(int, int, int)
,
fill(short[], int, int, short)
,
clone()
,
toString()
public ShortVector(short[] array) throws java.lang.NullPointerException
short
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(short[])
and by resize(int)
,
ensureSize(int)
methods.
array
- the short
array (must be non-null
) to
be wrapped.
java.lang.NullPointerException
- if array is null
.ShortVector()
,
ShortVector(int)
,
setArray(short[])
,
array()
,
resize(int)
,
ensureSize(int)
,
setAt(int, short)
,
getShortAt(int)
,
copyAt(int, int, int)
,
clone()
,
toString()
Method Detail |
---|
public void setArray(short[] 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 short
array (must be non-null
) to
be wrapped.
java.lang.NullPointerException
- if array is null
.ShortVector()
,
ShortVector(short[])
,
array()
,
resize(int)
,
ensureSize(int)
,
setAt(int, short)
,
getShortAt(int)
,
copyAt(int, int, int)
,
clone()
public final short[] array()
this
vector.
Important notes: this method does not copy array.
short
array (not null
), which is
wrapped.ShortVector(short[])
,
setArray(short[])
,
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(short[])
,
array()
,
setAt(int, short)
,
resize(int)
,
ensureSize(int)
,
getShortAt(int)
,
getAt(int)
public java.lang.Object getAt(int index) throws java.lang.ArrayIndexOutOfBoundsException
new Short(array()[index])
.
getAt
in interface Indexable
index
- the index (must be in the range) at which to return an element.
Short
) at index.
java.lang.ArrayIndexOutOfBoundsException
- if index is negative or is not less than
length()
.
java.lang.OutOfMemoryError
- if there is not enough memory.getShortAt(int)
,
array()
,
length()
public final short getShortAt(int index) throws java.lang.ArrayIndexOutOfBoundsException
array()[index]
.
index
- the index (must be in the range) at which to return an element.
short
element at index.
java.lang.ArrayIndexOutOfBoundsException
- if index is negative or is not less than
length()
.array()
,
length()
,
setAt(int, short)
,
resize(int)
,
ensureSize(int)
public void setAt(int index, short 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(short[])
,
array()
,
length()
,
getShortAt(int)
,
resize(int)
,
ensureSize(int)
,
copyAt(int, int, int)
,
fill(short[], int, int, short)
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, short)
,
getShortAt(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.ShortVector(int)
,
setArray(short[])
,
array()
,
length()
,
ensureSize(int)
,
resize(short[], 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, short)
,
resize(int)
,
ensureSize(short[], int)
public static final short[] resize(short[] 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(short[], int)
,
fill(short[], int, int, short)
public static final short[] ensureSize(short[] 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(short[], int)
,
fill(short[], int, int, short)
public static final void fill(short[] array, int offset, int len, short 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(short[], int, int, int, short[])
,
lastIndexOf(short[], int, int, int, short[])
,
toString(short[], int, int, char, boolean)
,
quickSort(short[], int, int, boolean)
,
binarySearch(short[], int, int, short, boolean)
public static final void reverse(short[] array) throws java.lang.NullPointerException
array
- the array (must be non-null
) to be reversed.
java.lang.NullPointerException
- if array is null
.array()
,
addTo(short[], short[])
,
subtractFrom(short[], short[])
,
countNonZero(short[])
,
indexOf(short, int, short[])
,
lastIndexOf(short, int, short[])
,
hashCode(short[])
,
equals(short[], short[])
,
compare(short[], int, int, short[], int, int, boolean)
,
mismatches(short[], int, short[], int, int)
public static final void addTo(short[] arrayA, short[] 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(short[])
,
subtractFrom(short[], short[])
,
multiplyBy(short[], short)
,
sumOf(short[], int, int, boolean)
,
scalarMul(short[], short[], boolean)
,
polynome(int, short[], boolean)
public static final void subtractFrom(short[] arrayA, short[] 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(short[], int, int, short)
,
reverse(short[])
,
addTo(short[], short[])
,
multiplyBy(short[], short)
,
sumOf(short[], int, int, boolean)
,
scalarMul(short[], short[], boolean)
,
polynome(int, short[], boolean)
public static final void multiplyBy(short[] array, short 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(short[], int, int, short)
,
reverse(short[])
,
addTo(short[], short[])
,
subtractFrom(short[], short[])
,
sumOf(short[], int, int, boolean)
,
scalarMul(short[], short[], boolean)
,
polynome(int, short[], boolean)
,
countNonZero(short[])
public static final int scalarMul(short[] arrayA, short[] arrayB, boolean isUnsigned) throws java.lang.NullPointerException
arrayA
- the first array (must be non-null
) to multiply.arrayB
- the second array (must be non-null
) to multiply.isUnsigned
- true
if and only if array elements are (treated as)
unsigned.
int
value).
java.lang.NullPointerException
- if arrayA is null
or arrayB is
null
.array()
,
addTo(short[], short[])
,
subtractFrom(short[], short[])
,
multiplyBy(short[], short)
,
sumOf(short[], int, int, boolean)
,
polynome(int, short[], boolean)
,
mismatches(short[], int, short[], int, int)
,
equals(short[], short[])
public static final int polynome(int intValue, short[] array, boolean isUnsigned) throws java.lang.NullPointerException
int
value into the polynome specified by its coefficients.
The result is the same as of
sum(array[index] * power(intValue, index))
. Overflow
is not checked. If length
of array is
zero then 0
is returned.
intValue
- the value to be substituted.array
- the array (must be non-null
) of the polynome
coefficients, arranged by their weight.isUnsigned
- true
if and only if array elements are (treated as)
unsigned.
java.lang.NullPointerException
- if array is null
.array()
,
addTo(short[], short[])
,
subtractFrom(short[], short[])
,
multiplyBy(short[], short)
,
scalarMul(short[], short[], boolean)
,
sumOf(short[], int, int, boolean)
,
countNonZero(short[])
public static final int sumOf(short[] array, int offset, int len, boolean isUnsigned) 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.isUnsigned
- true
if and only if array elements are (treated as)
unsigned.
int
value) for a given
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(short[], int, int, short)
,
addTo(short[], short[])
,
subtractFrom(short[], short[])
,
multiplyBy(short[], short)
,
countNonZero(short[])
,
hashCode(short[])
,
mismatches(short[], int, short[], int, int)
,
scalarMul(short[], short[], boolean)
,
polynome(int, short[], boolean)
public static final int countNonZero(short[] 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(short[], int, int, short)
,
sumOf(short[], int, int, boolean)
,
scalarMul(short[], short[], boolean)
,
polynome(int, short[], boolean)
,
equals(short[], short[])
,
compare(short[], int, int, short[], int, int, boolean)
,
mismatches(short[], int, short[], int, int)
public static final int indexOf(short value, int index, short[] array) throws java.lang.NullPointerException
length
of
array. If value is not found then the
result is -1
.
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(short, int, short[])
,
indexOf(short[], int, int, int, short[])
,
binarySearch(short[], int, int, short, boolean)
,
equals(short[], short[])
,
compare(short[], int, int, short[], int, int, boolean)
public static final int lastIndexOf(short value, int index, short[] 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
.
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(short, int, short[])
,
lastIndexOf(short[], int, int, int, short[])
,
binarySearch(short[], int, int, short, boolean)
,
reverse(short[])
,
equals(short[], short[])
,
compare(short[], int, int, short[], int, int, boolean)
public static final int indexOf(short[] subArray, int offset, int len, int index, short[] array) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
length
of array. If the
sequence is not found then the result is -1
.
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(short, int, short[])
,
lastIndexOf(short[], int, int, int, short[])
,
equals(short[], short[])
,
compare(short[], int, int, short[], int, int, boolean)
public static final int lastIndexOf(short[] subArray, int offset, int len, int index, short[] 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
.
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(short, int, short[])
,
indexOf(short[], int, int, int, short[])
,
equals(short[], short[])
,
compare(short[], int, int, short[], int, int, boolean)
public static final java.lang.String toString(short[] array, int offset, int len, char separator, boolean isUnsigned) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
short
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.isUnsigned
- true
if and only if array elements are (treated as)
unsigned.
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(short[], int, int, short)
,
quickSort(short[], int, int, boolean)
,
binarySearch(short[], int, int, short, boolean)
public static final int hashCode(short[] 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(short[], int, int, short)
,
reverse(short[])
,
sumOf(short[], int, int, boolean)
,
countNonZero(short[])
,
indexOf(short, int, short[])
,
lastIndexOf(short, int, short[])
,
equals(short[], short[])
,
compare(short[], int, int, short[], int, int, boolean)
,
mismatches(short[], int, short[], int, int)
public static final boolean equals(short[] arrayA, short[] 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.
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()
,
equals(java.lang.Object)
,
fill(short[], int, int, short)
,
reverse(short[])
,
subtractFrom(short[], short[])
,
scalarMul(short[], short[], boolean)
,
sumOf(short[], int, int, boolean)
,
indexOf(short, int, short[])
,
lastIndexOf(short, int, short[])
,
indexOf(short[], int, int, int, short[])
,
lastIndexOf(short[], int, int, int, short[])
,
hashCode(short[])
,
compare(short[], int, int, short[], int, int, boolean)
,
mismatches(short[], int, short[], int, int)
public static final int mismatches(short[] arrayA, int offsetA, short[] 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(short[], int, int, short)
,
reverse(short[])
,
subtractFrom(short[], short[])
,
scalarMul(short[], short[], boolean)
,
sumOf(short[], int, int, boolean)
,
countNonZero(short[])
,
hashCode(short[])
,
equals(short[], short[])
,
compare(short[], int, int, short[], int, int, boolean)
public static final int compare(short[] arrayA, int offsetA, int lenA, short[] arrayB, int offsetB, int lenB, boolean isUnsigned) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
short
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.
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.isUnsigned
- true
if and only if array elements are (treated as)
unsigned.
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(short[], int, int, short)
,
reverse(short[])
,
scalarMul(short[], short[], boolean)
,
polynome(int, short[], boolean)
,
sumOf(short[], int, int, boolean)
,
indexOf(short, int, short[])
,
lastIndexOf(short, int, short[])
,
hashCode(short[])
,
equals(short[], short[])
,
mismatches(short[], int, short[], int, int)
public static final void quickSort(short[] array, int offset, int len, boolean isUnsigned) 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.
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.isUnsigned
- true
if and only if array elements are (treated as)
unsigned.
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()
,
counterSort(short[], int, int, boolean)
,
binarySearch(short[], int, int, short, boolean)
,
fill(short[], int, int, short)
,
toString(short[], int, int, char, boolean)
public static final void counterSort(short[] array, int offset, int len, boolean isUnsigned) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
(SHORT_MASK + 1)
integer values is allocated. The
algorithm cost is linear but only for large regions. Negative
len is treated as zero. If an exception is thrown then
array remains unchanged. Else the region content is
altered.
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.isUnsigned
- true
if and only if array elements are (treated as)
unsigned.
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()
,
quickSort(short[], int, int, boolean)
,
binarySearch(short[], int, int, short, boolean)
,
fill(short[], int, int, short)
public static final int binarySearch(short[] array, int offset, int len, short value, boolean isUnsigned) 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.
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.isUnsigned
- true
if and only if value and array
elements are (treated as) unsigned.
(-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(short, int, short[])
,
lastIndexOf(short, int, short[])
,
quickSort(short[], int, int, boolean)
,
counterSort(short[], int, int, boolean)
,
fill(short[], int, int, short)
,
toString(short[], int, int, char, boolean)
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.ShortVector()
,
array()
,
getShortAt(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(short[])
,
array()
,
length()
,
getShortAt(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.
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.ShortVector()
,
equals(short[], short[])
,
array()
,
length()
,
getShortAt(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 (signed) manner, starting at index
0
.
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(short[], int, int, short[], int, int, boolean)
,
array()
,
length()
,
getShortAt(int)
,
equals(java.lang.Object)
public java.lang.String toString()
this
vector to its 'in-line' string
representation.
The decimal string representations of signed short
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(short[], int, int, char, boolean)
,
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.ShortVector(short[])
,
setArray(short[])
,
array()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |