Package redempt.redlex.processing
Class ArrayUtils
java.lang.Object
redempt.redlex.processing.ArrayUtils
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T[]
Concatenates two arraysstatic <T> T[]
Creates a new array with a single element removed from the input arraystatic <T> T[]
Remove elements from an arraystatic <T> T[]
removeRange
(T[] arr, int start, int end, Function<Integer, T[]> arrayConstructor) Removes a range of elements from an arraystatic <T> T[]
replaceRange
(T[] first, T[] second, int start, int end, Function<Integer, T[]> arrayConstructor) Replaces a range of an array with the contents of another array
-
Constructor Details
-
ArrayUtils
public ArrayUtils()
-
-
Method Details
-
remove
Remove elements from an array- Type Parameters:
T
- The type of the array- Parameters:
arr
- The array to remove elements fromarrayConstructor
- A function to create a new array of the given type with the given sizetoRemove
- The elements to remove, must all map to elements already in the array- Returns:
- The array with elements removed
-
concat
Concatenates two arrays- Type Parameters:
T
- The type of the array- Parameters:
first
- The first arraysecond
- The second arrayarrayConstructor
- A function to create a new array of the given type with the given size- Returns:
- The concatenated array
-
replaceRange
public static <T> T[] replaceRange(T[] first, T[] second, int start, int end, Function<Integer, T[]> arrayConstructor) Replaces a range of an array with the contents of another array- Type Parameters:
T
- The type of the array- Parameters:
first
- The array to replace the range insecond
- The array to insert in place of the replaced rangestart
- The starting index to replace from in the first array, inclusiveend
- The ending index to replace to in the first array, exclusivearrayConstructor
- A function to create a new array of the given type with the given size- Returns:
- The resulting array
-
remove
Creates a new array with a single element removed from the input array- Type Parameters:
T
- The type of the array- Parameters:
arr
- The array to remove the element fromindex
- The index of the element to removearrayConstructor
- A function to create a new array of the given type with the given size- Returns:
- The array with the element removed
-
removeRange
public static <T> T[] removeRange(T[] arr, int start, int end, Function<Integer, T[]> arrayConstructor) Removes a range of elements from an array- Type Parameters:
T
- The type of the array- Parameters:
arr
- The array to remove elements fromstart
- The start index to remove elements from, inclusiveend
- The end index to remove elements to, exclusivearrayConstructor
- A function to create a new array of the given type with the given size- Returns:
- The array with the range removed
-