Reusable Java library of general tools with minimal external dependencies.
For questions or support, please contact us:
Email: support@aoindustries.com
Phone: 1-800-519-9541
Phone: +1-251-607-9556
Web: https://www.aoindustries.com/contact
public class AoArrays extends Object
| Modifier and Type | Field and Description |
|---|---|
static byte[] |
EMPTY_BYTE_ARRAY |
static char[] |
EMPTY_CHAR_ARRAY |
static Class<?>[] |
EMPTY_CLASS_ARRAY |
static int[] |
EMPTY_INT_ARRAY |
static long[] |
EMPTY_LONG_ARRAY |
static Object[] |
EMPTY_OBJECT_ARRAY |
static Serializable[] |
EMPTY_SERIALIZABLE_ARRAY |
static String[] |
EMPTY_STRING_ARRAY |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
allEquals(byte[] b,
int off,
int len,
byte value)
Checks if all the values in the provided range are equal to
value. |
static <E> Set<E> |
asUnmodifiableSet(E... array)
Gets an unmodifiable set view with the contents of a backing array.
|
static int |
compare(byte[] ba1,
byte[] ba2)
Compares two byte[].
|
static boolean |
equals(byte[] b1,
byte[] b2,
int off,
int len)
Checks if the subrange of two byte arrays is equal.
|
static boolean |
equals(byte[] b1,
int off1,
byte[] b2,
int off2,
int len)
Checks if the subrange of two byte arrays is equal.
|
static int |
hashCode(byte[] a,
int off,
int len)
Computes hashCode compatible with Arrays.hashCode, but only across the
given subset of the array.
|
static int |
indexOf(byte[] array,
byte element)
Finds the first index of an element or
-1 if not found. |
static int |
indexOf(byte[] array,
byte element,
int fromIndex)
Finds the first index of an element or
-1 if not found. |
static int |
indexOf(char[] array,
char element)
Finds the first index of an element or
-1 if not found. |
static int |
indexOf(char[] array,
char element,
int fromIndex)
Finds the first index of an element or
-1 if not found. |
static int |
indexOf(double[] array,
double element)
Finds the first index of an element or
-1 if not found. |
static int |
indexOf(double[] array,
double element,
int fromIndex)
Finds the first index of an element or
-1 if not found. |
static <E> int |
indexOf(E[] array,
E element)
Finds the first index of an element or
-1 if not found. |
static <E extends Enum<E>> |
indexOf(E[] array,
E element)
Finds the first index of an element or
-1 if not found. |
static <E> int |
indexOf(E[] array,
E element,
int fromIndex)
Finds the first index of an element or
-1 if not found. |
static <E extends Enum<E>> |
indexOf(E[] array,
E element,
int fromIndex)
Finds the first index of an element or
-1 if not found. |
static int |
indexOf(float[] array,
float element)
Finds the first index of an element or
-1 if not found. |
static int |
indexOf(float[] array,
float element,
int fromIndex)
Finds the first index of an element or
-1 if not found. |
static int |
indexOf(int[] array,
int element)
Finds the first index of an element or
-1 if not found. |
static int |
indexOf(int[] array,
int element,
int fromIndex)
Finds the first index of an element or
-1 if not found. |
static int |
indexOf(long[] array,
long element)
Finds the first index of an element or
-1 if not found. |
static int |
indexOf(long[] array,
long element,
int fromIndex)
Finds the first index of an element or
-1 if not found. |
static int |
indexOf(short[] array,
short element)
Finds the first index of an element or
-1 if not found. |
static int |
indexOf(short[] array,
short element,
int fromIndex)
Finds the first index of an element or
-1 if not found. |
static int |
lastIndexOf(byte[] array,
byte element)
Finds the last index of an element or
-1 if not found. |
static int |
lastIndexOf(byte[] array,
byte element,
int fromIndex)
Finds the last index of an element or
-1 if not found. |
static int |
lastIndexOf(char[] array,
char element)
Finds the last index of an element or
-1 if not found. |
static int |
lastIndexOf(char[] array,
char element,
int fromIndex)
Finds the last index of an element or
-1 if not found. |
static int |
lastIndexOf(double[] array,
double element)
Finds the last index of an element or
-1 if not found. |
static int |
lastIndexOf(double[] array,
double element,
int fromIndex)
Finds the last index of an element or
-1 if not found. |
static <E> int |
lastIndexOf(E[] array,
E element)
Finds the last index of an element or
-1 if not found. |
static <E extends Enum<E>> |
lastIndexOf(E[] array,
E element)
Finds the last index of an element or
-1 if not found. |
static <E> int |
lastIndexOf(E[] array,
E element,
int fromIndex)
Finds the last index of an element or
-1 if not found. |
static <E extends Enum<E>> |
lastIndexOf(E[] array,
E element,
int fromIndex)
Finds the last index of an element or
-1 if not found. |
static int |
lastIndexOf(float[] array,
float element)
Finds the last index of an element or
-1 if not found. |
static int |
lastIndexOf(float[] array,
float element,
int fromIndex)
Finds the last index of an element or
-1 if not found. |
static int |
lastIndexOf(int[] array,
int element)
Finds the last index of an element or
-1 if not found. |
static int |
lastIndexOf(int[] array,
int element,
int fromIndex)
Finds the last index of an element or
-1 if not found. |
static int |
lastIndexOf(long[] array,
long element)
Finds the last index of an element or
-1 if not found. |
static int |
lastIndexOf(long[] array,
long element,
int fromIndex)
Finds the last index of an element or
-1 if not found. |
static int |
lastIndexOf(short[] array,
short element)
Finds the last index of an element or
-1 if not found. |
static int |
lastIndexOf(short[] array,
short element,
int fromIndex)
Finds the last index of an element or
-1 if not found. |
static <V> V[] |
merge(Class<V> clazz,
Collection<? extends Collection<? extends V>> collections,
Comparator<? super V> comparator)
Merges multiple already-sorted collections into one big array.
|
public static final byte[] EMPTY_BYTE_ARRAY
public static final char[] EMPTY_CHAR_ARRAY
public static final int[] EMPTY_INT_ARRAY
public static final long[] EMPTY_LONG_ARRAY
public static final Class<?>[] EMPTY_CLASS_ARRAY
public static final Object[] EMPTY_OBJECT_ARRAY
public static final Serializable[] EMPTY_SERIALIZABLE_ARRAY
public static final String[] EMPTY_STRING_ARRAY
public static boolean equals(byte[] b1,
byte[] b2,
int off,
int len)
public static boolean equals(byte[] b1,
int off1,
byte[] b2,
int off2,
int len)
public static boolean allEquals(byte[] b,
int off,
int len,
byte value)
value.public static int compare(byte[] ba1,
byte[] ba2)
public static <V> V[] merge(Class<V> clazz, Collection<? extends Collection<? extends V>> collections, Comparator<? super V> comparator)
public static <E> Set<E> asUnmodifiableSet(E... array)
Contains is implemented sequentially and is thus O(n). As a result, this is best used for very small sets.
In order to have correct set semantics, the array must have unique values as determined by the element equals methods. This is not checked, however, and passing in an array with duplicate values will result in duplicate values on iteration and a size that doesn't match the number of unique values.
public static <E> int indexOf(E[] array,
E element)
-1 if not found.public static <E> int indexOf(E[] array,
E element,
int fromIndex)
-1 if not found.public static <E> int lastIndexOf(E[] array,
E element)
-1 if not found.public static <E> int lastIndexOf(E[] array,
E element,
int fromIndex)
-1 if not found.public static <E extends Enum<E>> int indexOf(E[] array, E element)
-1 if not found.public static <E extends Enum<E>> int indexOf(E[] array, E element, int fromIndex)
-1 if not found.public static <E extends Enum<E>> int lastIndexOf(E[] array, E element)
-1 if not found.public static <E extends Enum<E>> int lastIndexOf(E[] array, E element, int fromIndex)
-1 if not found.public static int indexOf(byte[] array,
byte element)
-1 if not found.public static int indexOf(byte[] array,
byte element,
int fromIndex)
-1 if not found.public static int lastIndexOf(byte[] array,
byte element)
-1 if not found.public static int lastIndexOf(byte[] array,
byte element,
int fromIndex)
-1 if not found.public static int indexOf(short[] array,
short element)
-1 if not found.public static int indexOf(short[] array,
short element,
int fromIndex)
-1 if not found.public static int lastIndexOf(short[] array,
short element)
-1 if not found.public static int lastIndexOf(short[] array,
short element,
int fromIndex)
-1 if not found.public static int indexOf(int[] array,
int element)
-1 if not found.public static int indexOf(int[] array,
int element,
int fromIndex)
-1 if not found.public static int lastIndexOf(int[] array,
int element)
-1 if not found.public static int lastIndexOf(int[] array,
int element,
int fromIndex)
-1 if not found.public static int indexOf(long[] array,
long element)
-1 if not found.public static int indexOf(long[] array,
long element,
int fromIndex)
-1 if not found.public static int lastIndexOf(long[] array,
long element)
-1 if not found.public static int lastIndexOf(long[] array,
long element,
int fromIndex)
-1 if not found.public static int indexOf(float[] array,
float element)
-1 if not found.public static int indexOf(float[] array,
float element,
int fromIndex)
-1 if not found.public static int lastIndexOf(float[] array,
float element)
-1 if not found.public static int lastIndexOf(float[] array,
float element,
int fromIndex)
-1 if not found.public static int indexOf(double[] array,
double element)
-1 if not found.public static int indexOf(double[] array,
double element,
int fromIndex)
-1 if not found.public static int lastIndexOf(double[] array,
double element)
-1 if not found.public static int lastIndexOf(double[] array,
double element,
int fromIndex)
-1 if not found.public static int indexOf(char[] array,
char element)
-1 if not found.public static int indexOf(char[] array,
char element,
int fromIndex)
-1 if not found.public static int lastIndexOf(char[] array,
char element)
-1 if not found.public static int lastIndexOf(char[] array,
char element,
int fromIndex)
-1 if not found.public static int hashCode(byte[] a,
int off,
int len)
Arrays.hashCode(byte[])Copyright © 2000–2016 AO Industries, Inc.. All rights reserved.