|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ivmaidns.util.ObjectVector
public final class ObjectVector
Class for object array wrappers.
This class contains an Object
-type array, and has
the possibility to resize (when required) the contained array.
This class supports serialization (only if all its custom-type
elements are serializable), shallow cloning and comparison of its
instances. In addition, the class contains static
methods for Object
arrays resizing, filling in,
reversing, non-null
elements counting, linear/binary
searching in for a value or sequence, equality testing and
mismatches counting, hashing and 'to-string' conversion,
'greater-than' comparison and sorting according to the specified
comparator, 'less-equal-greater' comparison for
String
arrays. As a container, this class is similar
to ConstVector
, except that any vector of this class
is mutable and the contained array is the exact instance of
Object[]
.
ConstVector
,
ByteVector
,
CharVector
,
DoubleVector
,
FloatVector
,
IntVector
,
LongVector
,
ShortVector
,
BooleanVector
,
GComparator
,
Serialized FormField Summary | |
---|---|
protected java.lang.Object[] |
array
The encapsulated Object -type array. |
protected static java.lang.Object[] |
EMPTY
A constant initialized with an exact instance of empty Object array. |
Constructor Summary | |
---|---|
ObjectVector()
Constructs an empty Object vector. |
|
ObjectVector(int size)
Constructs a new Object vector of the specified
length. |
|
ObjectVector(java.lang.Object[] array)
Constructs a new initialized Object -type container. |
Method Summary | |
---|---|
java.lang.Object[] |
array()
Returns array encapsulated by this vector. |
static int |
binarySearch(java.lang.Object[] array,
int offset,
int len,
java.lang.Object value,
GComparator comparator)
Searches (fast) for value in a given sorted array. |
java.lang.Object |
clone()
Creates and returns a copy of this object. |
static int |
compare(java.lang.String[] arrayA,
int offsetA,
int lenA,
java.lang.String[] arrayB,
int offsetB,
int lenB)
Compares two given String 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 |
countNonNull(java.lang.Object[] array)
Count non- null elements in a given array. |
void |
ensureSize(int size)
Ensures the size (capacity) of this vector. |
static java.lang.Object[] |
ensureSize(java.lang.Object[] 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(java.lang.Object[] arrayA,
java.lang.Object[] arrayB)
Tests whether or not the specified two arrays are equal. |
static void |
fill(java.lang.Object[] array,
int offset,
int len,
java.lang.Object value)
Fills in the region of a given array with the specified value. |
java.lang.Object |
getAt(int index)
Returns value of the element at the specified index. |
static boolean |
greater(java.lang.Object[] arrayA,
java.lang.Object[] arrayB,
GComparator comparator)
Tests whether or not the first array is greater than the second one according to the supplied comparator. |
static boolean |
greater(Sortable[] arrayA,
Sortable[] arrayB)
Tests whether or not the first Sortable array is
greater than the second one. |
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(java.lang.Object[] array)
Produces a hash code value for a given array. |
static int |
indexOf(java.lang.Object[] subArray,
int offset,
int len,
int index,
java.lang.Object[] array)
Searches forward for the specified sequence in a given array. |
static int |
indexOf(java.lang.Object value,
int index,
java.lang.Object[] array)
Searches forward for value in a given array. |
void |
integrityCheck()
Verifies this object for its integrity. |
static int |
lastIndexOf(java.lang.Object[] subArray,
int offset,
int len,
int index,
java.lang.Object[] array)
Searches backward for the specified sequence in a given array. |
static int |
lastIndexOf(java.lang.Object value,
int index,
java.lang.Object[] array)
Searches backward for value in a given array. |
int |
length()
Returns the number of elements in this vector. |
static int |
mismatches(java.lang.Object[] arrayA,
int offsetA,
java.lang.Object[] arrayB,
int offsetB,
int len)
Count the mismatches of two given array regions. |
static int |
mismatchRemain(java.lang.Object[] arrayA,
int offsetA,
java.lang.Object[] arrayB,
int offsetB,
int len)
Tests two given array regions for non-equality and returns the distance between the end of the regions and the first found regions mismatch. |
static void |
quickSort(java.lang.Object[] array,
int offset,
int len,
GComparator comparator)
Sorts the elements in the region of a given array using 'Quick' algorithm according to the supplied comparator. |
void |
resize(int size)
Resizes this vector. |
static java.lang.Object[] |
resize(java.lang.Object[] array,
int size)
Resizes a given array. |
static void |
reverse(java.lang.Object[] array)
Reverses the elements order in a given array. |
void |
setArrayCloned(java.lang.Object[] array)
Sets another array to be encapsulated by this
vector. |
void |
setAt(int index,
java.lang.Object value)
Assigns a new value to the element at the specified index. |
static void |
sort(java.lang.Object[] array,
int offset,
int len,
GComparator comparator)
Sorts the objects in the region of a given array according to the supplied comparator. |
java.lang.Object[] |
toArray()
Returns a newly created array filled with the elements of this vector. |
java.lang.String |
toString()
Converts this vector to its string representation. |
static java.lang.String |
toString(java.lang.Object[] array,
int offset,
int len,
char separator)
Converts the region of a given array to its string representation. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.Object[] EMPTY
Object
array.
array
protected java.lang.Object[] array
Object
-type array.
array must be the exact instance of
Object[]
.
EMPTY
,
ObjectVector()
,
ObjectVector(int)
,
ObjectVector(java.lang.Object[])
,
setArrayCloned(java.lang.Object[])
,
array()
,
length()
,
toArray()
,
resize(int)
,
ensureSize(int)
,
setAt(int, java.lang.Object)
,
getAt(int)
,
copyAt(int, int, int)
,
clone()
,
integrityCheck()
Constructor Detail |
---|
public ObjectVector()
Object
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.
ObjectVector(int)
,
ObjectVector(java.lang.Object[])
,
array()
,
length()
,
resize(int)
,
ensureSize(int)
,
setAt(int, java.lang.Object)
,
getAt(int)
,
copyAt(int, int, int)
,
clone()
,
toString()
public ObjectVector(int size)
Object
vector of the specified
length.
This constructor is typically used for the creation of a vector
with a fixed size. All the elements of the created vector are set
to null
.
size
- the initial length (unsigned) of the vector to be created.
java.lang.OutOfMemoryError
- if there is not enough memory.ObjectVector()
,
ObjectVector(java.lang.Object[])
,
array()
,
length()
,
setAt(int, java.lang.Object)
,
getAt(int)
,
copyAt(int, int, int)
,
fill(java.lang.Object[], int, int, java.lang.Object)
,
clone()
,
toString()
public ObjectVector(java.lang.Object[] array) throws java.lang.NullPointerException
Object
-type container.
This constructor is used for the creation of a vector which
contains the copy of the specified array (the component type of
the copy is always set to Object
type). The
encapsulated array may be further replaced with another one only
by setArrayCloned(Object[])
and by
resize(int)
, ensureSize(int)
methods.
array
- the Object
array (must be non-null
) to
be copied and encapsulated.
java.lang.NullPointerException
- if array is null
.
java.lang.OutOfMemoryError
- if there is not enough memory.ObjectVector()
,
ObjectVector(int)
,
setArrayCloned(java.lang.Object[])
,
array()
,
toArray()
,
resize(int)
,
ensureSize(int)
,
setAt(int, java.lang.Object)
,
getAt(int)
,
copyAt(int, int, int)
,
clone()
,
toString()
Method Detail |
---|
public void setArrayCloned(java.lang.Object[] array) throws java.lang.NullPointerException
this
vector.
If an exception is thrown then this
vector remains
unchanged. Else this method creates a new Object
array and copies the content of the supplied array
into it.
array
- the Object
array (must be non-null
) to
be copied and encapsulated.
java.lang.NullPointerException
- if array is null
.
java.lang.OutOfMemoryError
- if there is not enough memory.ObjectVector()
,
ObjectVector(java.lang.Object[])
,
array()
,
toArray()
,
resize(int)
,
ensureSize(int)
,
setAt(int, java.lang.Object)
,
getAt(int)
,
copyAt(int, int, int)
,
clone()
public final java.lang.Object[] array()
this
vector.
Important notes: this method does not copy array.
null
).ObjectVector(java.lang.Object[])
,
setArrayCloned(java.lang.Object[])
,
toArray()
,
length()
,
resize(int)
,
ensureSize(int)
,
copyAt(int, int, int)
,
clone()
public java.lang.Object[] toArray()
this
vector.
The result is the exact instance of Object[]
(with
the same length
as of this vector).
null
) of the encapsulated array.
java.lang.OutOfMemoryError
- if there is not enough memory.ObjectVector(java.lang.Object[])
,
setArrayCloned(java.lang.Object[])
,
array()
,
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.setArrayCloned(java.lang.Object[])
,
array()
,
setAt(int, java.lang.Object)
,
resize(int)
,
ensureSize(int)
,
getAt(int)
public java.lang.Object getAt(int index) throws java.lang.ArrayIndexOutOfBoundsException
array()[index]
.
getAt
in interface Indexable
index
- the index (must be in the range) at which to return an element.
null
) at index.
java.lang.ArrayIndexOutOfBoundsException
- if index is negative or is not less than
length()
.array()
,
length()
,
setAt(int, java.lang.Object)
,
resize(int)
,
ensureSize(int)
public void setAt(int index, java.lang.Object 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 (may be null
) to be assigned.
java.lang.ArrayIndexOutOfBoundsException
- if index is negative or is not less than
length()
.setArrayCloned(java.lang.Object[])
,
array()
,
length()
,
getAt(int)
,
resize(int)
,
ensureSize(int)
,
copyAt(int, int, int)
,
fill(java.lang.Object[], int, int, java.lang.Object)
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, java.lang.Object)
,
getAt(int)
,
resize(int)
,
ensureSize(int)
public void resize(int size)
this
vector.
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 null
. 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.ObjectVector(int)
,
setArrayCloned(java.lang.Object[])
,
array()
,
length()
,
ensureSize(int)
,
resize(java.lang.Object[], int)
public void ensureSize(int size)
this
vector.
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
null
. 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, java.lang.Object)
,
resize(int)
,
ensureSize(java.lang.Object[], int)
public static final java.lang.Object[] resize(java.lang.Object[] array, int size) throws java.lang.NullPointerException
Object
-type
array and copies the content into it) the length of the specified
array to the specified one. Important notes: array
elements are not changed; if 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
null
in it, the component type of the new array is
always set to Object
).
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(java.lang.Object[], int)
,
fill(java.lang.Object[], int, int, java.lang.Object)
public static final java.lang.Object[] ensureSize(java.lang.Object[] array, int size) throws java.lang.NullPointerException
Object
-type array and copies the content into it,
but only if size is greater than 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 null
in it, the component type
of the new array is always set to Object
).
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(java.lang.Object[], int)
,
fill(java.lang.Object[], int, int, java.lang.Object)
public static final void fill(java.lang.Object[] array, int offset, int len, java.lang.Object value) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException, java.lang.ArrayStoreException
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 (may be null
) 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).
java.lang.ArrayStoreException
- if value could not be stored into array.array()
,
copyAt(int, int, int)
,
toString(java.lang.Object[], int, int, char)
,
sort(java.lang.Object[], int, int, net.sf.ivmaidns.util.GComparator)
,
binarySearch(java.lang.Object[], int, int,
java.lang.Object, net.sf.ivmaidns.util.GComparator)
public static final void reverse(java.lang.Object[] array) throws java.lang.NullPointerException
array
- the array (must be non-null
) to be reversed.
java.lang.NullPointerException
- if array is null
.array()
,
countNonNull(java.lang.Object[])
,
indexOf(java.lang.Object, int, java.lang.Object[])
,
lastIndexOf(java.lang.Object, int, java.lang.Object[])
,
hashCode(java.lang.Object[])
,
equals(java.lang.Object[], java.lang.Object[])
,
mismatches(java.lang.Object[], int, java.lang.Object[],
int, int)
public static final int countNonNull(java.lang.Object[] array) throws java.lang.NullPointerException
null
elements in a given array.
This method returns the count of elements of array
which are not null
.
array
- the array (must be non-null
) to count
non-null
elements in.
length
of array) of non-null
elements.
java.lang.NullPointerException
- if array is null
.array()
,
fill(java.lang.Object[], int, int, java.lang.Object)
,
equals(java.lang.Object[], java.lang.Object[])
,
mismatches(java.lang.Object[], int, java.lang.Object[],
int, int)
public static final int indexOf(java.lang.Object value, int index, java.lang.Object[] array) throws java.lang.NullPointerException
length
of
array. If value is not found then the
result is -1
. Important notes: value is
tested for equality against the elements.
value
- the value (may be null
) 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()
,
equals(java.lang.Object[], java.lang.Object[])
,
lastIndexOf(java.lang.Object, int, java.lang.Object[])
,
indexOf(java.lang.Object[], int, int, int,
java.lang.Object[])
public static final int lastIndexOf(java.lang.Object value, int index, java.lang.Object[] 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: value
is tested for equality against the elements.
value
- the value (may be null
) 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()
,
reverse(java.lang.Object[])
,
equals(java.lang.Object[], java.lang.Object[])
,
indexOf(java.lang.Object, int, java.lang.Object[])
,
lastIndexOf(java.lang.Object[], int, int, int,
java.lang.Object[])
public static final int indexOf(java.lang.Object[] subArray, int offset, int len, int index, java.lang.Object[] array) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
length
of array. If the
sequence is not found then the result is -1
.
Important notes: the elements of subArray are tested
for equality against the elements of array.
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()
,
equals(java.lang.Object[], java.lang.Object[])
,
indexOf(java.lang.Object, int, java.lang.Object[])
,
lastIndexOf(java.lang.Object[], int, int, int,
java.lang.Object[])
public static final int lastIndexOf(java.lang.Object[] subArray, int offset, int len, int index, java.lang.Object[] 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: the elements of
subArray are tested for equality against the elements
of array.
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()
,
equals(java.lang.Object[], java.lang.Object[])
,
lastIndexOf(java.lang.Object, int, java.lang.Object[])
,
indexOf(java.lang.Object[], int, int, int,
java.lang.Object[])
public static final java.lang.String toString(java.lang.Object[] array, int offset, int len, char separator) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
null
then "null") 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(java.lang.Object[], int, int, java.lang.Object)
public static final int hashCode(java.lang.Object[] array) throws java.lang.NullPointerException
null
then its hash code is
assumed to be 0
.
array
- the array (must be non-null
) to evaluate hash of.
java.lang.NullPointerException
- if array is null
.array()
,
hashCode()
,
fill(java.lang.Object[], int, int, java.lang.Object)
,
countNonNull(java.lang.Object[])
,
indexOf(java.lang.Object, int, java.lang.Object[])
,
lastIndexOf(java.lang.Object, int, java.lang.Object[])
,
equals(java.lang.Object[], java.lang.Object[])
,
mismatches(java.lang.Object[], int, java.lang.Object[],
int, int)
public static final boolean equals(java.lang.Object[] arrayA, java.lang.Object[] 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: the component type of arrays is not
compared.
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(java.lang.Object[], int, int, java.lang.Object)
,
indexOf(java.lang.Object, int, java.lang.Object[])
,
lastIndexOf(java.lang.Object, int, java.lang.Object[])
,
hashCode(java.lang.Object[])
,
mismatchRemain(java.lang.Object[], int, java.lang.Object[],
int, int)
public static final int mismatchRemain(java.lang.Object[] arrayA, int offsetA, java.lang.Object[] 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(java.lang.Object[], int, int, java.lang.Object)
,
reverse(java.lang.Object[])
,
countNonNull(java.lang.Object[])
,
hashCode(java.lang.Object[])
,
equals(java.lang.Object[], java.lang.Object[])
,
mismatches(java.lang.Object[], int, java.lang.Object[],
int, int)
public static final int mismatches(java.lang.Object[] arrayA, int offsetA, java.lang.Object[] 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(java.lang.Object[], int, int, java.lang.Object)
,
reverse(java.lang.Object[])
,
countNonNull(java.lang.Object[])
,
hashCode(java.lang.Object[])
,
equals(java.lang.Object[], java.lang.Object[])
,
greater(java.lang.Object[], java.lang.Object[],
net.sf.ivmaidns.util.GComparator)
public static final boolean greater(java.lang.Object[] arrayA, java.lang.Object[] arrayB, GComparator comparator) throws java.lang.NullPointerException
Object
arrays are compared here in the
element-by-element manner, starting at index 0
, and
at each index elements are tested for equality and the first
found non-equal elements pair is compared using
comparator (returning the result of this final
comparison). Important notes: if there is no non-equal elements
pairs then the first array is considered to be greater than the
second one only if its length is greater; the component type of
arrays is not compared anyway.
arrayA
- the first array (must be non-null
) to be compared.arrayB
- the second array (must be non-null
) to compare with.comparator
- the 'greater-than' comparator (must be non-null
) to
use.
true
if arrayA is semantically greater
than arrayB, else false
.
java.lang.NullPointerException
- if arrayA is null
or arrayB is
null
, or comparator is null
.array()
,
length()
,
greaterThan(java.lang.Object)
,
indexOf(java.lang.Object, int, java.lang.Object[])
,
lastIndexOf(java.lang.Object, int, java.lang.Object[])
,
hashCode(java.lang.Object[])
,
equals(java.lang.Object[], java.lang.Object[])
,
sort(java.lang.Object[], int, int, net.sf.ivmaidns.util.GComparator)
,
greater(net.sf.ivmaidns.util.Sortable[],
net.sf.ivmaidns.util.Sortable[])
,
compare(java.lang.String[], int, int, java.lang.String[],
int, int)
public static final boolean greater(Sortable[] arrayA, Sortable[] arrayB) throws java.lang.NullPointerException
Sortable
array is
greater than the second one.
Sortable
arrays are compared here in the
element-by-element manner, starting at index 0
, and
at each index elements are tested for equality and the first
found non-equal elements pair is compared using the appropriate
greaterThan(Object)
method (returning the result of
this final comparison). Important notes: if there is no non-equal
elements pairs then the first array is considered to be greater
than the second one only if its length is greater; the component
type of arrays is not compared anyway.
arrayA
- the first array (must be non-null
) to be compared.arrayB
- the second array (must be non-null
) to compare with.
true
if arrayA is semantically greater
than arrayB, else false
.
java.lang.NullPointerException
- if arrayA is null
or arrayB is
null
.array()
,
length()
,
equals(java.lang.Object[], java.lang.Object[])
,
greater(java.lang.Object[], java.lang.Object[],
net.sf.ivmaidns.util.GComparator)
public static final int compare(java.lang.String[] arrayA, int offsetA, int lenA, java.lang.String[] arrayB, int offsetB, int lenB) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
String
array regions.
This method returns a signed integer indicating
'less-equal-greater' case-sensitive relation between the
specified array regions of strings (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 null
element is considered to be greater than a non-null
one.
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()
,
length()
,
equals(java.lang.Object[], java.lang.Object[])
,
greater(net.sf.ivmaidns.util.Sortable[],
net.sf.ivmaidns.util.Sortable[])
,
greater(java.lang.Object[], java.lang.Object[],
net.sf.ivmaidns.util.GComparator)
public static final void sort(java.lang.Object[] array, int offset, int len, GComparator comparator) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
((len + 1) / 2)
objects is allocated. The algorithm
cost is O(log(len) * len)
in worst case, but may be
near O(len)
for nearly sorted arrays. 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.comparator
- the 'greater-than' comparator (must be non-null
) to
use.
java.lang.NullPointerException
- if array is null
or comparator
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(java.lang.Object[], int, int,
net.sf.ivmaidns.util.GComparator)
public static final void quickSort(java.lang.Object[] array, int offset, int len, GComparator comparator) 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.comparator
- the 'greater-than' comparator (must be non-null
) to
use.
java.lang.NullPointerException
- if array is null
or comparator
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()
,
sort(java.lang.Object[], int, int, net.sf.ivmaidns.util.GComparator)
,
binarySearch(java.lang.Object[], int, int,
java.lang.Object, net.sf.ivmaidns.util.GComparator)
public static final int binarySearch(java.lang.Object[] array, int offset, int len, java.lang.Object value, GComparator comparator) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
O(log(len))
.
The elements are compared against value. 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 (may be null
) to search for.comparator
- the 'greater-than' comparator (must be non-null
) to
use.
(-insertionOffset - 1)
(a negative integer) if not
found.
java.lang.NullPointerException
- if array is null
or comparator
is null
.
java.lang.ArrayIndexOutOfBoundsException
- if len is positive and (offset is negative
or is greater than length
of array minus
len).array()
,
fill(java.lang.Object[], int, int, java.lang.Object)
,
indexOf(java.lang.Object, int, java.lang.Object[])
,
lastIndexOf(java.lang.Object, int, java.lang.Object[])
,
sort(java.lang.Object[], int, int, net.sf.ivmaidns.util.GComparator)
,
quickSort(java.lang.Object[], int, int,
net.sf.ivmaidns.util.GComparator)
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.ObjectVector()
,
array()
,
toArray()
,
getAt(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(java.lang.Object[])
,
array()
,
length()
,
getAt(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 the
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.ObjectVector()
,
array()
,
length()
,
getAt(int)
,
hashCode()
,
greaterThan(java.lang.Object)
,
equals(java.lang.Object[], 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. Object
vectors
are compared in the element-by-element manner, starting at index
0
and at each index elements are tested for equality
and the first non-equal elements pair is compared using
INSTANCE
of GComparator
class.
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
.array()
,
getAt(int)
,
length()
,
equals(java.lang.Object)
,
greater(java.lang.Object[], java.lang.Object[],
net.sf.ivmaidns.util.GComparator)
public java.lang.String toString()
this
vector to its string representation.
The string representations of the objects (if a value is
null
then "null") of the encapsulated
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(java.lang.Object[], int, int, char)
,
getAt(int)
,
length()
public void integrityCheck()
this
object for its integrity.
The array component type and array elements are not checked.
For debug purpose only.
integrityCheck
in interface Verifiable
java.lang.InternalError
- if integrity violation is detected.ObjectVector(java.lang.Object[])
,
setArrayCloned(java.lang.Object[])
,
array()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |