|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectStatic
XArrays
public final class XArrays
Simple operations on arrays. This class provides a central place for inserting and deleting elements in an array, as well as resizing the array.
The resize methods provided in this class are very similar to the copyOf
methods provided in Arrays since Java 6, except that they accept null
arrays and do not copy anything if the given array already has the requested length.
Arrays
| utility/geotk-utility (download) | View source code for this class |
| Field Summary | |
|---|---|
static boolean[] |
EMPTY_BOOLEAN
An empty array of boolean primitive type. |
static byte[] |
EMPTY_BYTE
An empty array of byte primitive type. |
static char[] |
EMPTY_CHAR
An empty array of char primitive type. |
static double[] |
EMPTY_DOUBLE
An empty array of double primitive type. |
static float[] |
EMPTY_FLOAT
An empty array of float primitive type. |
static int[] |
EMPTY_INT
An empty array of int primitive type. |
static long[] |
EMPTY_LONG
An empty array of long primitive type. |
static short[] |
EMPTY_SHORT
An empty array of short primitive type. |
| Method Summary | ||
|---|---|---|
static boolean |
allEquals(double[] array,
double value)
Returns true if all values in the specified array are equal to the specified
value, which may be Double.NaN. |
|
static boolean |
allEquals(float[] array,
float value)
Returns true if all values in the specified array are equal to the specified
value, which may be Float.NaN. |
|
static
|
append(T[] array,
T element)
Returns a copy of the given array with a single element appended at the end. |
|
static
|
concatenate(T[]... arrays)
Returns the concatenation of all given arrays. |
|
static boolean |
contains(Object[] array,
Object value)
Returns true if the specified array contains the specified value. |
|
static boolean |
containsIdentity(Object[] array,
Object value)
Returns true if the specified array contains the specified reference. |
|
static boolean |
containsIgnoreCase(String[] array,
String value)
Returns true if the specified array contains the specified value, ignoring case. |
|
static float[] |
copyAsFloats(double[] data)
Returns a copy of the given array where each value has been casted to the float type. |
|
static int[] |
copyAsInts(double[] data)
Returns a copy of the given array where each value has been rounded to the int type. |
|
static boolean |
hasNaN(double[] array)
Returns true if the specified array contains at least one
NaN value. |
|
static boolean |
hasNaN(float[] array)
Returns true if the specified array contains at least one
NaN value. |
|
static boolean[] |
insert(boolean[] src,
int srcOff,
boolean[] dst,
int dstOff,
int length)
Returns an array containing the same elements than the given array, with the content of an other array inserted at the given index. |
|
static boolean[] |
insert(boolean[] array,
int first,
int length)
Returns an array containing the same elements than the given array, with additional "spaces" in the given range. |
|
static byte[] |
insert(byte[] src,
int srcOff,
byte[] dst,
int dstOff,
int length)
Returns an array containing the same elements than the given array, with the content of an other array inserted at the given index. |
|
static byte[] |
insert(byte[] array,
int first,
int length)
Returns an array containing the same elements than the given array, with additional "spaces" in the given range. |
|
static char[] |
insert(char[] src,
int srcOff,
char[] dst,
int dstOff,
int length)
Returns an array containing the same elements than the given array, with the content of an other array inserted at the given index. |
|
static char[] |
insert(char[] array,
int first,
int length)
Returns an array containing the same elements than the given array, with additional "spaces" in the given range. |
|
static double[] |
insert(double[] src,
int srcOff,
double[] dst,
int dstOff,
int length)
Returns an array containing the same elements than the given array, with the content of an other array inserted at the given index. |
|
static double[] |
insert(double[] array,
int first,
int length)
Returns an array containing the same elements than the given array, with additional "spaces" in the given range. |
|
static
|
insert(E[] src,
int srcOff,
E[] dst,
int dstOff,
int length)
Returns an array containing the same elements than the given array, with the content of an other array inserted at the given index. |
|
static
|
insert(E[] array,
int first,
int length)
Returns an array containing the same elements than the given array, with additional "spaces" in the given range. |
|
static float[] |
insert(float[] src,
int srcOff,
float[] dst,
int dstOff,
int length)
Returns an array containing the same elements than the given array, with the content of an other array inserted at the given index. |
|
static float[] |
insert(float[] array,
int first,
int length)
Returns an array containing the same elements than the given array, with additional "spaces" in the given range. |
|
static int[] |
insert(int[] array,
int first,
int length)
Returns an array containing the same elements than the given array, with additional "spaces" in the given range. |
|
static int[] |
insert(int[] src,
int srcOff,
int[] dst,
int dstOff,
int length)
Returns an array containing the same elements than the given array, with the content of an other array inserted at the given index. |
|
static long[] |
insert(long[] array,
int first,
int length)
Returns an array containing the same elements than the given array, with additional "spaces" in the given range. |
|
static long[] |
insert(long[] src,
int srcOff,
long[] dst,
int dstOff,
int length)
Returns an array containing the same elements than the given array, with the content of an other array inserted at the given index. |
|
static short[] |
insert(short[] array,
int first,
int length)
Returns an array containing the same elements than the given array, with additional "spaces" in the given range. |
|
static short[] |
insert(short[] src,
int srcOff,
short[] dst,
int dstOff,
int length)
Returns an array containing the same elements than the given array, with the content of an other array inserted at the given index. |
|
static boolean |
intersects(Object[] array1,
Object[] array2)
Returns true if at least one element in the first array is equals to an element in the second array. |
|
static boolean |
isSorted(byte[] array,
boolean strict)
Returns true if all elements in the specified array are in increasing order. |
|
static boolean |
isSorted(char[] array,
boolean strict)
Returns true if all elements in the specified array are in increasing order. |
|
static boolean |
isSorted(double[] array,
boolean strict)
Returns true if all elements in the specified array are in increasing order. |
|
static
|
isSorted(E[] array,
Comparator<E> comparator,
boolean strict)
Returns true if all elements in the specified array are in increasing order. |
|
static boolean |
isSorted(float[] array,
boolean strict)
Returns true if all elements in the specified array are in increasing order. |
|
static boolean |
isSorted(int[] array,
boolean strict)
Returns true if all elements in the specified array are in increasing order. |
|
static boolean |
isSorted(long[] array,
boolean strict)
Returns true if all elements in the specified array are in increasing order. |
|
static boolean |
isSorted(short[] array,
boolean strict)
Returns true if all elements in the specified array are in increasing order. |
|
static boolean[] |
remove(boolean[] array,
int first,
int length)
Returns an array containing the same elements than the given array except for the given range. |
|
static byte[] |
remove(byte[] array,
int first,
int length)
Returns an array containing the same elements than the given array except for the given range. |
|
static char[] |
remove(char[] array,
int first,
int length)
Returns an array containing the same elements than the given array except for the given range. |
|
static double[] |
remove(double[] array,
int first,
int length)
Returns an array containing the same elements than the given array except for the given range. |
|
static
|
remove(E[] array,
int first,
int length)
Returns an array containing the same elements than the given array except for the given range. |
|
static float[] |
remove(float[] array,
int first,
int length)
Returns an array containing the same elements than the given array except for the given range. |
|
static int[] |
remove(int[] array,
int first,
int length)
Returns an array containing the same elements than the given array except for the given range. |
|
static long[] |
remove(long[] array,
int first,
int length)
Returns an array containing the same elements than the given array except for the given range. |
|
static short[] |
remove(short[] array,
int first,
int length)
Returns an array containing the same elements than the given array except for the given range. |
|
static boolean[] |
resize(boolean[] array,
int length)
Returns an array containing the same elements as the given array but
specified length, truncating or padding with false if necessary. |
|
static byte[] |
resize(byte[] array,
int length)
Returns an array containing the same elements as the given array but
specified length, truncating or padding with zeros if necessary. |
|
static char[] |
resize(char[] array,
int length)
Returns an array containing the same elements as the given array but
specified length, truncating or padding with zeros if necessary. |
|
static double[] |
resize(double[] array,
int length)
Returns an array containing the same elements as the given array but
specified length, truncating or padding with zeros if necessary. |
|
static
|
resize(E[] array,
int length)
Returns an array containing the same elements as the given array but with the
specified length, truncating or padding with null if necessary. |
|
static float[] |
resize(float[] array,
int length)
Returns an array containing the same elements as the given array but
specified length, truncating or padding with zeros if necessary. |
|
static int[] |
resize(int[] array,
int length)
Returns an array containing the same elements as the given array but
specified length, truncating or padding with zeros if necessary. |
|
static long[] |
resize(long[] array,
int length)
Returns an array containing the same elements as the given array but
specified length, truncating or padding with zeros if necessary. |
|
static short[] |
resize(short[] array,
int length)
Returns an array containing the same elements as the given array but
specified length, truncating or padding with zeros if necessary. |
|
static void |
reverse(Object[] entries)
Reverses the order of elements in the given array. |
|
static int[] |
union(int[] array1,
int[] array2)
Returns the union of two sorted arrays. |
|
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final double[] EMPTY_DOUBLE
double primitive type.
Such arrays are immutable and can be safely shared.
public static final float[] EMPTY_FLOAT
float primitive type.
Such arrays are immutable and can be safely shared.
public static final long[] EMPTY_LONG
long primitive type.
Such arrays are immutable and can be safely shared.
public static final int[] EMPTY_INT
int primitive type.
Such arrays are immutable and can be safely shared.
public static final short[] EMPTY_SHORT
short primitive type.
Such arrays are immutable and can be safely shared.
public static final byte[] EMPTY_BYTE
byte primitive type.
Such arrays are immutable and can be safely shared.
public static final char[] EMPTY_CHAR
char primitive type.
Such arrays are immutable and can be safely shared.
public static final boolean[] EMPTY_BOOLEAN
boolean primitive type.
Such arrays are immutable and can be safely shared.
| Method Detail |
|---|
public static <E> E[] resize(E[] array,
int length)
array but with the
specified length, truncating or padding with null if necessary.
If the given length is longer than the length of the given array,
then the returned array will contain all the elements of array at index
i < array.length. Elements at index i >=
array.length are initialized to null.
If the given length is shorter than the length of the given array,
then the returned array will contain only the elements of array at index
i < length. Remainding elements are not copied.
If the given length is equal to the length of the given array,
then array is returned unchanged. No copy is performed.
This behavior is what make this method different than Arrays.copyOf(T[], int).
E - The array elements.array - Array to resize, or null.length - Length of the desired array.
array if the given
array is null or already have the requested length.Arrays.copyOf(Object[],int)
public static double[] resize(double[] array,
int length)
array but
specified length, truncating or padding with zeros if necessary.
array - Array to resize, or null.length - Length of the desired array.
array if the given
array is null or already have the requested length.Arrays.copyOf(double[],int)
public static float[] resize(float[] array,
int length)
array but
specified length, truncating or padding with zeros if necessary.
array - Array to resize, or null.length - Length of the desired array.
array if the given
array is null or already have the requested length.Arrays.copyOf(float[],int)
public static long[] resize(long[] array,
int length)
array but
specified length, truncating or padding with zeros if necessary.
array - Array to resize, or null.length - Length of the desired array.
array if the given
array is null or already have the requested length.Arrays.copyOf(long[],int)
public static int[] resize(int[] array,
int length)
array but
specified length, truncating or padding with zeros if necessary.
array - Array to resize, or null.length - Length of the desired array.
array if the given
array is null or already have the requested length.Arrays.copyOf(int[],int)
public static short[] resize(short[] array,
int length)
array but
specified length, truncating or padding with zeros if necessary.
array - Array to resize, or null.length - Length of the desired array.
array if the given
array is null or already have the requested length.Arrays.copyOf(short[],int)
public static byte[] resize(byte[] array,
int length)
array but
specified length, truncating or padding with zeros if necessary.
array - Array to resize, or null.length - Length of the desired array.
array if the given
array is null or already have the requested length.Arrays.copyOf(byte[],int)
public static char[] resize(char[] array,
int length)
array but
specified length, truncating or padding with zeros if necessary.
array - Array to resize, or null.length - Length of the desired array.
array if the given
array is null or already have the requested length.Arrays.copyOf(char[],int)
public static boolean[] resize(boolean[] array,
int length)
array but
specified length, truncating or padding with false if necessary.
array - Array to resize, or null.length - Length of the desired array.
array if the given
array is null or already have the requested length.Arrays.copyOf(boolean[],int)
public static <E> E[] remove(E[] array,
int first,
int length)
length argument is 0, then this method returns
the array reference unchanged (except if empty). Otherwise this method
creates a new array. In every cases, the given array is never modified.
E - The type of array elements.array - Array from which to remove elements.first - Index of the first element to remove from the given array.length - Number of elements to remove.
array except for the
removed elements, or array if length is 0.
public static double[] remove(double[] array,
int first,
int length)
length argument is 0, then this method returns
the array reference unchanged (except if empty). Otherwise this method
creates a new array. In every cases, the given array is never modified.
array - Array from which to remove elements.first - Index of the first element to remove from the given array.length - Number of elements to remove.
array except for the
removed elements, or array if length is 0.
public static float[] remove(float[] array,
int first,
int length)
length argument is 0, then this method returns
the array reference unchanged (except if empty). Otherwise this method
creates a new array. In every cases, the given array is never modified.
array - Array from which to remove elements.first - Index of the first element to remove from the given array.length - Number of elements to remove.
array except for the
removed elements, or array if length is 0.
public static long[] remove(long[] array,
int first,
int length)
length argument is 0, then this method returns
the array reference unchanged (except if empty). Otherwise this method
creates a new array. In every cases, the given array is never modified.
array - Array from which to remove elements.first - Index of the first element to remove from the given array.length - Number of elements to remove.
array except for the
removed elements, or array if length is 0.
public static int[] remove(int[] array,
int first,
int length)
length argument is 0, then this method returns
the array reference unchanged (except if empty). Otherwise this method
creates a new array. In every cases, the given array is never modified.
array - Array from which to remove elements.first - Index of the first element to remove from the given array.length - Number of elements to remove.
array except for the
removed elements, or array if length is 0.
public static short[] remove(short[] array,
int first,
int length)
length argument is 0, then this method returns
the array reference unchanged (except if empty). Otherwise this method
creates a new array. In every cases, the given array is never modified.
array - Array from which to remove elements.first - Index of the first element to remove from the given array.length - Number of elements to remove.
array except for the
removed elements, or array if length is 0.
public static byte[] remove(byte[] array,
int first,
int length)
length argument is 0, then this method returns
the array reference unchanged (except if empty). Otherwise this method
creates a new array. In every cases, the given array is never modified.
array - Array from which to remove elements.first - Index of the first element to remove from the given array.length - Number of elements to remove.
array except for the
removed elements, or array if length is 0.
public static char[] remove(char[] array,
int first,
int length)
length argument is 0, then this method returns
the array reference unchanged (except if empty). Otherwise this method
creates a new array. In every cases, the given array is never modified.
array - Array from which to remove elements.first - Index of the first element to remove from the given array.length - Number of elements to remove.
array except for the
removed elements, or array if length is 0.
public static boolean[] remove(boolean[] array,
int first,
int length)
length argument is 0, then this method returns
the array reference unchanged (except if empty). Otherwise this method
creates a new array. In every cases, the given array is never modified.
array - Array from which to remove elements.first - Index of the first element to remove from the given array.length - Number of elements to remove.
array except for the
removed elements, or array if length is 0.
public static <E> E[] insert(E[] array,
int first,
int length)
null elements.
If the length argument is 0, then this method returns the array
reference unchanged. Otherwise this method creates a new array. In every cases,
the given array is never modified.
E - The type of array elements.array - Array in which to insert spaces.first - Index where the first space should be inserted. All array elements
having an index equal to or higher than index will be moved forward.length - Number of spaces to insert.
array elements with the additional space
inserted, or array if length is 0.
public static double[] insert(double[] array,
int first,
int length)
If the length argument is 0, then this method returns the array
reference unchanged. Otherwise this method creates a new array. In every cases,
the given array is never modified.
array - Array in which to insert spaces.first - Index where the first space should be inserted. All array elements
having an index equal to or higher than index will be moved forward.length - Number of spaces to insert.
array elements with the additional space
inserted, or array if length is 0.
public static float[] insert(float[] array,
int first,
int length)
If the length argument is 0, then this method returns the array
reference unchanged. Otherwise this method creates a new array. In every cases,
the given array is never modified.
array - Array in which to insert spaces.first - Index where the first space should be inserted. All array elements
having an index equal to or higher than index will be moved forward.length - Number of spaces to insert.
array elements with the additional space
inserted, or array if length is 0.
public static long[] insert(long[] array,
int first,
int length)
If the length argument is 0, then this method returns the array
reference unchanged. Otherwise this method creates a new array. In every cases,
the given array is never modified.
array - Array in which to insert spaces.first - Index where the first space should be inserted. All array elements
having an index equal to or higher than index will be moved forward.length - Number of spaces to insert.
array elements with the additional space
inserted, or array if length is 0.
public static int[] insert(int[] array,
int first,
int length)
If the length argument is 0, then this method returns the array
reference unchanged. Otherwise this method creates a new array. In every cases,
the given array is never modified.
array - Array in which to insert spaces.first - Index where the first space should be inserted. All array elements
having an index equal to or higher than index will be moved forward.length - Number of spaces to insert.
array elements with the additional space
inserted, or array if length is 0.
public static short[] insert(short[] array,
int first,
int length)
If the length argument is 0, then this method returns the array
reference unchanged. Otherwise this method creates a new array. In every cases,
the given array is never modified.
array - Array in which to insert spaces.first - Index where the first space should be inserted. All array elements
having an index equal to or higher than index will be moved forward.length - Number of spaces to insert.
array elements with the additional space
inserted, or array if length is 0.
public static byte[] insert(byte[] array,
int first,
int length)
If the length argument is 0, then this method returns the array
reference unchanged. Otherwise this method creates a new array. In every cases,
the given array is never modified.
array - Array in which to insert spaces.first - Index where the first space should be inserted. All array elements
having an index equal to or higher than index will be moved forward.length - Number of spaces to insert.
array elements with the additional space
inserted, or array if length is 0.
public static char[] insert(char[] array,
int first,
int length)
If the length argument is 0, then this method returns the array
reference unchanged. Otherwise this method creates a new array. In every cases,
the given array is never modified.
array - Array in which to insert spaces.first - Index where the first space should be inserted. All array elements
having an index equal to or higher than index will be moved forward.length - Number of spaces to insert.
array elements with the additional space
inserted, or array if length is 0.
public static boolean[] insert(boolean[] array,
int first,
int length)
false.
If the length argument is 0, then this method returns the array
reference unchanged. Otherwise this method creates a new array. In every cases,
the given array is never modified.
array - Array in which to insert spaces.first - Index where the first space should be inserted. All array elements
having an index equal to or higher than index will be moved forward.length - Number of spaces to insert.
array elements with the additional space
inserted, or array if length is 0.
public static <E> E[] insert(E[] src,
int srcOff,
E[] dst,
int dstOff,
int length)
If the length argument is 0, then this method returns the dst
reference unchanged. Otherwise this method creates a new array. In every cases,
the given arrays are never modified.
E - The type of array elements.src - Array to entirely or partially insert into dst.srcOff - Index of the first element of src to insert into dst.dst - Array in which to insert src data.dstOff - Index of the first element in dst where to insert src data.
All elements of dst whose index is equal to or greater than
dstOff will be moved forward.length - Number of src elements to insert.
src and dst. This method
returns directly dst when length is zero, but never return
src.
public static double[] insert(double[] src,
int srcOff,
double[] dst,
int dstOff,
int length)
If the length argument is 0, then this method returns the dst
reference unchanged. Otherwise this method creates a new array. In every cases,
the given arrays are never modified.
src - Array to entirely or partially insert into dst.srcOff - Index of the first element of src to insert into dst.dst - Array in which to insert src data.dstOff - Index of the first element in dst where to insert src data.
All elements of dst whose index is equal to or greater than
dstOff will be moved forward.length - Number of src elements to insert.
src and dst. This method
returns directly dst when length is zero, but never return
src.
public static float[] insert(float[] src,
int srcOff,
float[] dst,
int dstOff,
int length)
If the length argument is 0, then this method returns the dst
reference unchanged. Otherwise this method creates a new array. In every cases,
the given arrays are never modified.
src - Array to entirely or partially insert into dst.srcOff - Index of the first element of src to insert into dst.dst - Array in which to insert src data.dstOff - Index of the first element in dst where to insert src data.
All elements of dst whose index is equal to or greater than
dstOff will be moved forward.length - Number of src elements to insert.
src and dst. This method
returns directly dst when length is zero, but never return
src.
public static long[] insert(long[] src,
int srcOff,
long[] dst,
int dstOff,
int length)
If the length argument is 0, then this method returns the dst
reference unchanged. Otherwise this method creates a new array. In every cases,
the given arrays are never modified.
src - Array to entirely or partially insert into dst.srcOff - Index of the first element of src to insert into dst.dst - Array in which to insert src data.dstOff - Index of the first element in dst where to insert src data.
All elements of dst whose index is equal to or greater than
dstOff will be moved forward.length - Number of src elements to insert.
src and dst. This method
returns directly dst when length is zero, but never return
src.
public static int[] insert(int[] src,
int srcOff,
int[] dst,
int dstOff,
int length)
If the length argument is 0, then this method returns the dst
reference unchanged. Otherwise this method creates a new array. In every cases,
the given arrays are never modified.
src - Array to entirely or partially insert into dst.srcOff - Index of the first element of src to insert into dst.dst - Array in which to insert src data.dstOff - Index of the first element in dst where to insert src data.
All elements of dst whose index is equal to or greater than
dstOff will be moved forward.length - Number of src elements to insert.
src and dst. This method
returns directly dst when length is zero, but never return
src.
public static short[] insert(short[] src,
int srcOff,
short[] dst,
int dstOff,
int length)
If the length argument is 0, then this method returns the dst
reference unchanged. Otherwise this method creates a new array. In every cases,
the given arrays are never modified.
src - Array to entirely or partially insert into dst.srcOff - Index of the first element of src to insert into dst.dst - Array in which to insert src data.dstOff - Index of the first element in dst where to insert src data.
All elements of dst whose index is equal to or greater than
dstOff will be moved forward.length - Number of src elements to insert.
src and dst. This method
returns directly dst when length is zero, but never return
src.
public static byte[] insert(byte[] src,
int srcOff,
byte[] dst,
int dstOff,
int length)
If the length argument is 0, then this method returns the dst
reference unchanged. Otherwise this method creates a new array. In every cases,
the given arrays are never modified.
src - Array to entirely or partially insert into dst.srcOff - Index of the first element of src to insert into dst.dst - Array in which to insert src data.dstOff - Index of the first element in dst where to insert src data.
All elements of dst whose index is equal to or greater than
dstOff will be moved forward.length - Number of src elements to insert.
src and dst. This method
returns directly dst when length is zero, but never return
src.
public static char[] insert(char[] src,
int srcOff,
char[] dst,
int dstOff,
int length)
If the length argument is 0, then this method returns the dst
reference unchanged. Otherwise this method creates a new array. In every cases,
the given arrays are never modified.
src - Array to entirely or partially insert into dst.srcOff - Index of the first element of src to insert into dst.dst - Array in which to insert src data.dstOff - Index of the first element in dst where to insert src data.
All elements of dst whose index is equal to or greater than
dstOff will be moved forward.length - Number of src elements to insert.
src and dst. This method
returns directly dst when length is zero, but never return
src.
public static boolean[] insert(boolean[] src,
int srcOff,
boolean[] dst,
int dstOff,
int length)
If the length argument is 0, then this method returns the dst
reference unchanged. Otherwise this method creates a new array. In every cases,
the given arrays are never modified.
src - Array to entirely or partially insert into dst.srcOff - Index of the first element of src to insert into dst.dst - Array in which to insert src data.dstOff - Index of the first element in dst where to insert src data.
All elements of dst whose index is equal to or greater than
dstOff will be moved forward.length - Number of src elements to insert.
src and dst. This method
returns directly dst when length is zero, but never return
src.
public static <T> T[] append(T[] array,
T element)
ArrayList instead.
T - The type of elements in the array.array - The array to copy with a new element. The original array will not be modified.element - The element to add (can be null).
concatenate(Object[][])public static void reverse(Object[] entries)
entries - The array in which to reverse the order of elements.public static float[] copyAsFloats(double[] data)
float type.
data - The array to copy, or null.
float type, or
null if the given array was null.public static int[] copyAsInts(double[] data)
int type.
data - The array to copy, or null.
int type, or
null if the given array was null.
public static <E> boolean isSorted(E[] array,
Comparator<E> comparator,
boolean strict)
true if all elements in the specified array are in increasing order.
This method is useful in assertions.
E - The type of array elements.array - The array to test for order.comparator - The comparator to use for comparing order.strict - true if elements should be strictly sorted (i.e. equal
elements are not allowed}, or false otherwise.
true if all elements in the given array are sorted in increasing order.
public static boolean isSorted(double[] array,
boolean strict)
true if all elements in the specified array are in increasing order.
Since NaN values are unordered, they may appears anywhere in the array; they
will be ignored. This method is useful in assertions.
array - The array to test for order.strict - true if elements should be strictly sorted (i.e. equal elements
are not allowed}, or false otherwise.
true if all elements in the given array are sorted in increasing order.
public static boolean isSorted(float[] array,
boolean strict)
true if all elements in the specified array are in increasing order.
Since NaN values are unordered, they may appears anywhere in the array; they
will be ignored. This method is useful in assertions.
array - The array to test for order.strict - true if elements should be strictly sorted (i.e. equal elements
are not allowed}, or false otherwise.
true if all elements in the given array are sorted in increasing order.
public static boolean isSorted(long[] array,
boolean strict)
true if all elements in the specified array are in increasing order.
This method is useful in assertions.
array - The array to test for order.strict - true if elements should be strictly sorted (i.e. equal elements
are not allowed}, or false otherwise.
true if all elements in the given array are sorted in increasing order.
public static boolean isSorted(int[] array,
boolean strict)
true if all elements in the specified array are in increasing order.
This method is useful in assertions.
array - The array to test for order.strict - true if elements should be strictly sorted (i.e. equal elements
are not allowed}, or false otherwise.
true if all elements in the given array are sorted in increasing order.
public static boolean isSorted(short[] array,
boolean strict)
true if all elements in the specified array are in increasing order.
This method is useful in assertions.
array - The array to test for order.strict - true if elements should be strictly sorted (i.e. equal elements
are not allowed}, or false otherwise.
true if all elements in the given array are sorted in increasing order.
public static boolean isSorted(byte[] array,
boolean strict)
true if all elements in the specified array are in increasing order.
This method is useful in assertions.
array - The array to test for order.strict - true if elements should be strictly sorted (i.e. equal elements
are not allowed}, or false otherwise.
true if all elements in the given array are sorted in increasing order.
public static boolean isSorted(char[] array,
boolean strict)
true if all elements in the specified array are in increasing order.
This method is useful in assertions.
array - The array to test for order.strict - true if elements should be strictly sorted (i.e. equal elements
are not allowed}, or false otherwise.
true if all elements in the given array are sorted in increasing order.
public static boolean allEquals(double[] array,
double value)
true if all values in the specified array are equal to the specified
value, which may be Double.NaN.
array - The array to check.value - The expected value.
true if all elements in the given array are equal to the given value.
public static boolean allEquals(float[] array,
float value)
true if all values in the specified array are equal to the specified
value, which may be Float.NaN.
array - The array to check.value - The expected value.
true if all elements in the given array are equal to the given value.public static boolean hasNaN(double[] array)
true if the specified array contains at least one
NaN value.
array - The array to check.
true if the given array contains at least one NaN value.public static boolean hasNaN(float[] array)
true if the specified array contains at least one
NaN value.
array - The array to check.
true if the given array contains at least one NaN value.
public static boolean containsIgnoreCase(String[] array,
String value)
true if the specified array contains the specified value, ignoring case.
This method should be used only for very small arrays.
array - The array to search in. May be null.value - The value to search.
true if the array is non-null and contains the given value,
or false otherwise.
public static boolean containsIdentity(Object[] array,
Object value)
true if the specified array contains the specified reference.
The comparisons are performed using the == operator.
This method should be used only for very small arrays, or for searches to be performed
only once, because it performs a linear search. If more than one search need to be done
on the same array, consider using IdentityHashMap instead.
array - The array to search in. May be null and may contains null elements.value - The value to search. May be null.
true if the array is non-null and contains the value (which may be null),
or false otherwise.
public static boolean contains(Object[] array,
Object value)
true if the specified array contains the specified value.
The comparisons are performed using the Object.equals(Object) method.
This method should be used only for very small arrays, or for searches to be performed
only once, because it performs a linear search. If more than one search need to be done
on the same array, consider using HashSet instead.
array - The array to search in. May be null and may contains null elements.value - The value to search. May be null.
true if the array is non-null and contains the value (which may be null),
or false otherwise.
public static boolean intersects(Object[] array1,
Object[] array2)
true if at least one element in the first array is equals to an element in the second array. The element doesn't need to be at the same index
in both array.
This method should be used only for very small arrays since it may be very slow. If the
arrays are large or if an array will be involved in more than one search, consider using
HashSet instead.
array1 - The first array.array2 - The second array.
true if both array have at least one element in common.public static <T> T[] concatenate(T[]... arrays)
arrays argument is null or contains only null
elements, then this method returns null.arrays argument contains exactly one non-null array with
a length greater than zero, then that array is returned. It is not copied.
T - The type of arrays.arrays - The arrays to concatenate, or null.
null.append(Object[], Object)
public static int[] union(int[] array1,
int[] array2)
array1 - The first array.array2 - The second array.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||