public final class ArrayExtensions extends Object
ArrayExtensions is an extensions class for use with array objects.| Constructor and Description |
|---|
ArrayExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T[] |
arraycopyWithSystem(T[] source,
T[] destination)
Copy the given source array to the given destination array.
|
static <T> List<T> |
asList(T[] array)
Creates a new
List from the given array. |
static <T> Set<T> |
asSet(T... array)
Creates a new
Set from the given array. |
static <T> boolean |
contains(T[] array,
T element)
Returns true if and only if the given element is in the given array
|
static <T> T |
getFirst(T[] array)
Gets the first object from the given array.
|
static <T> int |
getIndex(T[] array,
T element)
Gets the index of the given element in the given array.
|
static <T> T |
getLast(T[] array)
Gets the last object from the given array.
|
static <T> int |
getNextIndex(T[] array,
T element)
Gets the next index of the given array.
|
static <T> int[] |
getNextIndexes(T[] array,
T element,
int count)
Gets the next indexes from the given count of the given array.
|
static <T> int |
getPreviousIndex(T[] array,
T element)
Gets the previous index of the given array.
|
static <T> int[] |
getPreviousIndexes(T[] array,
T element,
int count)
Gets the previous indexes from the given count of the given array.
|
static <T> int |
indexOf(T[] array,
T element)
Gets the index of the given element in the given array.
|
static <T> T[] |
intersection(T[] one,
T[] other)
Intersection of the given two arrays.
|
static <T> boolean |
isFirst(T[] array,
T element)
Checks if the given element is the first in the given array.
|
static <T> boolean |
isLast(T[] array,
T element)
Checks if the given element is the last in the given array.
|
static <T> T[] |
remove(T[] array,
int... indexes)
Removes the first element of the array.
|
static <T> T[] |
removeAll(T[] array,
T[] arrayToRemove)
Removes the first element of the array.
|
static <T> T[] |
removeFirst(T[] original)
Creates a new array cloned from the given array with the difference that the first element is
removed
|
static <T> T[] |
removeFromEnd(T[] array,
T[] suffix)
Removes the given suffix array from the first given array
|
static <T> T[] |
removeFromStart(T[] array,
T[] prefix)
Removes the given prefix array from the first given array
|
static <T> T[] |
removeLast(T[] original)
Removes the first element of the array
|
static byte[][] |
splitInChunks(byte[] bytes,
int chunkSize)
Split the given byte array in to new arrays with the chunk size.
|
static <T> List<T> |
toList(T[] array)
Creates a new
List from the given array. |
public static <T> T[] removeFromStart(@NonNull
T[] array,
@NonNull
T[] prefix)
T - the generic type of the objects in the arraysarray - the arrayprefix - the prefixpublic static <T> T[] removeFromEnd(T[] array,
T[] suffix)
T - the generic type of the objects in the arraysarray - the arraysuffix - the suffixpublic static <T> T[] removeAll(@NonNull
T[] array,
@NonNull
T[] arrayToRemove)
T - the generic type of the objects in the arrayarray - the origin arrayarrayToRemove - the array to removepublic static <T> boolean contains(T[] array,
T element)
T - the generic typearray - the arrayelement - the elementpublic static <T> T[] remove(@NonNull
T[] array,
int... indexes)
T - the generic type of the objects in the arrayarray - the origin arrayindexes - the indexes to removepublic static <T> T[] removeFirst(@NonNull
T[] original)
T - the generic type of the objects in the arrayoriginal - the origin arraypublic static <T> T[] removeLast(@NonNull
T[] original)
T - the generic type of the objects in the arrayoriginal - the origin arraypublic static <T> T[] arraycopyWithSystem(T[] source,
T[] destination)
Integer[] source = {1,2,3,4,5,6,7,8,9};
Integer[] destination = new Integer[source.length];
destination = ArrayExtensions.arraycopyWithSystem(source, destination);
T - the generic type of the objects in the arraysource - the sourcedestination - the destination@SafeVarargs public static <T> Set<T> asSet(T... array)
T - the generic type of the objects in the array.array - the arraySet created from the given array.public static <T> List<T> asList(T[] array)
List from the given array. Arrays.asList(Object...).T - the generic type of the objects in the array.array - the arrayList created from the given array.public static <T> T getFirst(T[] array)
T - the generic typearray - the array.public static <T> int getIndex(T[] array,
T element)
T - the generic typearray - the arrayelement - the elementpublic static <T> T getLast(T[] array)
T - the generic typearray - the array.public static <T> int getNextIndex(T[] array,
T element)
T - the generic typearray - the arrayelement - the elementpublic static <T> int[] getNextIndexes(T[] array,
T element,
int count)
T - the generic typearray - the arrayelement - the elementcount - the countpublic static <T> int getPreviousIndex(T[] array,
T element)
T - the generic typearray - the arrayelement - the elementpublic static <T> int[] getPreviousIndexes(T[] array,
T element,
int count)
T - the generic typearray - the arrayelement - the elementcount - the countpublic static <T> T[] intersection(@NonNull
T[] one,
@NonNull
T[] other)
T - the generic typeone - the first arrayother - the other arraypublic static <T> int indexOf(T[] array,
T element)
T - the generic typearray - the arrayelement - the elementpublic static <T> boolean isFirst(T[] array,
T element)
T - the generic typearray - the arrayelement - the elementpublic static <T> boolean isLast(T[] array,
T element)
T - the generic typearray - the arrayelement - the elementpublic static byte[][] splitInChunks(byte[] bytes,
int chunkSize)
bytes - the byteschunkSize - the chunk sizepublic static <T> List<T> toList(T[] array)
List from the given array. Arrays.asList(Object...).T - the generic type of the objects in the array.array - the arrayList created from the given array.Copyright © 2015–2019 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.