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 int
binarySearch
(double[] array, double value, double tolerance) Return the index ofvalue
inarray
, or-1
if 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 void
reverseArray
(byte[] array, int offset, int length) Reverse thelength
values on the array starting fromoffset
.static void
reverseSubArray
(double[] array, int offset, int length) Reverse thelength
values on the array starting fromoffset
.static void
reverseSubArray
(long[] array, int offset, int length) Reverse thelength
values on the array starting fromoffset
.
-
Method Details
-
binarySearch
public static int binarySearch(double[] array, double value, double tolerance) Return the index ofvalue
inarray
, or-1
if there is no such index. If there are several values that are withintolerance
or 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 thelength
values on the array starting fromoffset
. -
reverseSubArray
public static void reverseSubArray(long[] array, int offset, int length) Reverse thelength
values on the array starting fromoffset
. -
reverseArray
public static void reverseArray(byte[] array, int offset, int length) Reverse thelength
values on the array starting fromoffset
.
-