public class Arrs extends PrimitiveArrays
BOOLEAN_ARRAY_CLASS, BYTE_ARRAY_CLASS, CHAR_ARRAY_CLASS, DOUBLE_ARRAY_CLASS, FLOAT_ARRAY_CLASS, INDEX_NOT_FOUND, INT_ARRAY_CLASS, LONG_ARRAY_CLASS, PRIMITIVE_ARRAY_CLASSES, SHORT_ARRAY_CLASS| 构造器和说明 |
|---|
Arrs() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
contains(Object[] array,
Object objectToFind) |
static <E> E[] |
copy(E... objs) |
static <E> E[] |
createArray(Class<E> componentType,
int length)
Create an array with the specified length.
|
static <E> E[] |
createArray(Class<E> componentType,
int length,
E initValue)
Create an array with the specified length and every element's value is the specified initValue
|
static <E> E[] |
createArray(Class<E> componentType,
int length,
Supplier<Integer,E> initSupplier)
Create an array with the specified length and every element's value is supplied by the specified initSupplier
|
static boolean |
deepEquals(Object[] a1,
Object[] a2) |
static boolean |
deepEquals(Object e1,
Object e2) |
static int |
getLength(Object object)
get the length if argument is an array, else -1
|
static int |
indexOf(Object[] array,
Object objectToFind,
int startIndex) |
static <T> int |
indexOf(T[] array,
Object objectToFind) |
static <E> void |
initArray(E[] array,
E initValue) |
static <E> void |
initArray(E[] array,
Supplier<Integer,E> initSupplier) |
static boolean |
isArray(Object o)
judge whether an object is an Array
|
static <E> boolean |
isMixedArray(E[] objs) |
static boolean |
isNegativeIndex(int length,
int index)
判断是否为负数索引
|
static boolean |
isPositiveIndex(int length,
int index)
判断是否为正数索引
|
static boolean |
isValidIndex(int length,
int index)
判断索引是否有效
|
static Integer[] |
range(int end)
It is similar to Python's range(start, end, step)
[start, end)
|
static Integer[] |
range(int start,
int end)
It is similar to Python's range(start, end, step)
[start, end)
|
static Integer[] |
range(int start,
int end,
int step)
It is similar to Python's range(start, end, step)
[start, end)
|
static int |
reverseIndex(int length,
int index) |
static int |
reverseIndex(int length,
int index,
boolean positiveNegativeInterChangeMode)
正负之间反转索引:
0, 1, 2, 3, 4 // 正序遍历时的索引
-5, -4, -3 -2, -1 // 倒序遍历时的索引
前后颠倒反转索引:
0, 1, 2, 3, 4 // 正序遍历时的索引
4, 3, 2 1, 0 // 倒序遍历是的索引
|
static <E> void |
swap(E[] arr,
int i,
int j)
Swaps the two specified elements in the specified array.
|
static int |
toPositiveIndex(int length,
int index) |
static int[] |
toPositiveIndexes(int length,
int fromIndex,
int toIndex) |
static <E> E[] |
wrapAsArray(E o)
Wrap any object using new Object[]{object};
|
clone, clone, clone, clone, clone, clone, clone, clone, clone, copy, copy, copy, copy, copy, copy, copy, copy, createBooleanArray, createBooleanArray, createByteArray, createByteArray, createCharArray, createCharArray, createDoubleArray, createDoubleArray, createFloatArray, createFloatArray, createIntArray, createIntArray, createLongArray, createLongArray, createShortArray, createShortArray, equals, equals, equals, equals, equals, equals, equals, equals, equals, equals, equals, equals, equals, equals, equals, equals, equals, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, indexOf, insert, insert, insert, insert, insert, insert, insert, insert, insert, isPrimitiveArray, unwrap, unwrap, unwrap, unwrap, unwrap, unwrap, unwrap, unwrap, wrap, wrap, wrap, wrap, wrap, wrap, wrap, wrap, wrappublic static int getLength(Object object)
object - any objectpublic static <E> E[] wrapAsArray(@Nullable E o)
public static <E> E[] createArray(@Nullable Class<E> componentType, int length)
int.class => Integer[] Integer.class => Integer[]
public static <E> E[] createArray(@Nullable Class<E> componentType, int length, @Nullable E initValue)
public static <E> E[] createArray(@Nullable Class<E> componentType, int length, @NonNull Supplier<Integer,E> initSupplier)
public static <E> void initArray(@NonNull E[] array, @NonNull Supplier<Integer,E> initSupplier)
public static Integer[] range(int end)
range(int, int, int)public static Integer[] range(int start, int end)
range(int, int, int)public static Integer[] range(int start, int end, int step)
public static <E> void swap(@NonNull E[] arr, int i, int j)
public static int toPositiveIndex(int length,
int index)
public static int[] toPositiveIndexes(int length,
int fromIndex,
int toIndex)
public static int reverseIndex(int length,
int index)
public static int reverseIndex(int length,
int index,
boolean positiveNegativeInterChangeMode)
public static boolean isValidIndex(int length,
int index)
public static boolean isPositiveIndex(int length,
int index)
public static boolean isNegativeIndex(int length,
int index)
public static <T> int indexOf(T[] array,
Object objectToFind)
public static <E> E[] copy(E... objs)
public static <E> boolean isMixedArray(E[] objs)
Copyright © 2022. All rights reserved.