public final class ArrayUtils extends Object
Modifier and Type | Method and Description |
---|---|
static byte[] |
allocate(long... sizes)
Allocates a 1-dimensional byte array matching the product of the given
sizes.
|
static <T> T[] |
array(T... values)
Creates an array of the given type, containing the specified values.
|
static boolean |
contains(boolean[] array,
boolean value)
Returns true if the given value is contained in the specified array.
|
static boolean |
contains(byte[] array,
byte value)
Returns true if the given value is contained in the specified array.
|
static boolean |
contains(char[] array,
char value)
Returns true if the given value is contained in the specified array.
|
static boolean |
contains(double[] array,
double value)
Returns true if the given value is contained in the specified array.
|
static boolean |
contains(float[] array,
float value)
Returns true if the given value is contained in the specified array.
|
static boolean |
contains(int[] array,
int value)
Returns true if the given value is contained in the specified array.
|
static boolean |
contains(long[] array,
long value)
Returns true if the given value is contained in the specified array.
|
static boolean |
contains(Object[] array,
Object value)
Returns true if the given value is contained in the specified array.
|
static boolean |
contains(short[] array,
short value)
Returns true if the given value is contained in the specified array.
|
static int |
indexOf(boolean[] array,
boolean value)
Returns the index of the first occurrence of the given value in the given
array.
|
static int |
indexOf(byte[] array,
byte value)
Returns the index of the first occurrence of the given value in the given
array.
|
static int |
indexOf(char[] array,
char value)
Returns the index of the first occurrence of the given value in the given
array.
|
static int |
indexOf(double[] array,
double value)
Returns the index of the first occurrence of the given value in the given
array.
|
static int |
indexOf(float[] array,
float value)
Returns the index of the first occurrence of the given value in the given
array.
|
static int |
indexOf(int[] array,
int value)
Returns the index of the first occurrence of the given value in the given
array.
|
static int |
indexOf(long[] array,
long value)
Returns the index of the first occurrence of the given value in the given
array.
|
static int |
indexOf(Object[] array,
Object value)
Returns the index of the first occurrence of the given value in the given
Object array.
|
static int |
indexOf(short[] array,
short value)
Returns the index of the first occurrence of the given value in the given
array.
|
static int |
safeMultiply32(long... sizes)
Checks that the product of the given sizes does not exceed the 32-bit
integer limit (i.e.,
Integer.MAX_VALUE ). |
static long |
safeMultiply64(long... sizes)
Checks that the product of the given sizes does not exceed the 64-bit
integer limit (i.e.,
Long.MAX_VALUE ). |
static Collection<?> |
toCollection(Object value)
Converts the provided Object to a
Collection implementation. |
@SafeVarargs public static <T> T[] array(T... values)
public static Collection<?> toCollection(Object value)
Collection
implementation. If the
object is an array type, a PrimitiveArray
wrapper will be created.public static byte[] allocate(long... sizes) throws IllegalArgumentException
sizes
- list of sizes from which to allocate the arrayIllegalArgumentException
- if the total size exceeds 2GB, which is
the maximum size of an array in Java; or if any size argument is
zero or negativepublic static int safeMultiply32(long... sizes) throws IllegalArgumentException
Integer.MAX_VALUE
).sizes
- list of sizes from which to compute the productIllegalArgumentException
- if the total size exceeds 2GiB, which is
the maximum size of an int in Java; or if any size argument is
zero or negativepublic static long safeMultiply64(long... sizes) throws IllegalArgumentException
Long.MAX_VALUE
).sizes
- list of sizes from which to compute the productIllegalArgumentException
- if the total size exceeds 8EiB, which is
the maximum size of a long in Java; or if any size argument is
zero or negativepublic static boolean contains(byte[] array, byte value)
public static boolean contains(boolean[] array, boolean value)
public static boolean contains(char[] array, char value)
public static boolean contains(double[] array, double value)
public static boolean contains(float[] array, float value)
public static boolean contains(int[] array, int value)
public static boolean contains(long[] array, long value)
public static boolean contains(short[] array, short value)
public static boolean contains(Object[] array, Object value)
public static int indexOf(boolean[] array, boolean value)
public static int indexOf(byte[] array, byte value)
public static int indexOf(char[] array, char value)
public static int indexOf(double[] array, double value)
public static int indexOf(float[] array, float value)
public static int indexOf(int[] array, int value)
public static int indexOf(long[] array, long value)
public static int indexOf(short[] array, short value)
Copyright © 2015–2022 SciJava. All rights reserved.