java.lang.Object
org.elasticsearch.common.util.ArrayUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T[]append(T[] array, T added) Copy the given array and the added element into a new array of sizearray.length + 1.static intbinarySearch(double[] array, double value, double tolerance) Return the index ofvalueinarray, or-1if there is no such index.static <T> T[]concat(T[] one, T[] other) Concatenates 2 arraysstatic <T> T[]prepend(T added, T[] array) Copy the given element and array into a new array of sizearray.length + 1.static voidreverseArray(byte[] array, int offset, int length) Reverse thelengthvalues on the array starting fromoffset.static voidreverseSubArray(double[] array, int offset, int length) Reverse thelengthvalues on the array starting fromoffset.static voidreverseSubArray(long[] array, int offset, int length) Reverse thelengthvalues on the array starting fromoffset.
-
Method Details
-
binarySearch
public static int binarySearch(double[] array, double value, double tolerance) Return the index ofvalueinarray, or-1if there is no such index. If there are several values that are withintoleranceor less ofvalue, this method will return the index of the closest value. In case of several values being as close otvalue, there is no guarantee which index will be returned. Results are undefined if the array is not sorted. -
concat
public static <T> T[] concat(T[] one, T[] other) Concatenates 2 arrays -
prepend
public static <T> T[] prepend(T added, T[] array) Copy the given element and array into a new array of sizearray.length + 1.- Type Parameters:
T- type of the array elements- Parameters:
added- first element in the newly created arrayarray- array to copy to the end of new returned array copy- Returns:
- copy that contains added element and array
-
append
public static <T> T[] append(T[] array, T added) Copy the given array and the added element into a new array of sizearray.length + 1.- Type Parameters:
T- type of the array elements- Parameters:
array- array to copy to the beginning of new returned array copyadded- last element in the newly created array- Returns:
- copy that contains array and added element
-
reverseSubArray
public static void reverseSubArray(double[] array, int offset, int length) Reverse thelengthvalues on the array starting fromoffset. -
reverseSubArray
public static void reverseSubArray(long[] array, int offset, int length) Reverse thelengthvalues on the array starting fromoffset. -
reverseArray
public static void reverseArray(byte[] array, int offset, int length) Reverse thelengthvalues on the array starting fromoffset.
-