Class ArrayUtils

java.lang.Object
org.elasticsearch.common.util.ArrayUtils

public class ArrayUtils extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T[]
    append(T[] array, T added)
    Copy the given array and the added element into a new array of size array.length + 1.
    static int
    binarySearch(double[] array, double value, double tolerance)
    Return the index of value in array, or -1 if there is no such index.
    static <T> T[]
    concat(T[] one, T[] other)
    Concatenates 2 arrays
    static void
    reverseSubArray(double[] array, int offset, int length)
    Reverse the length values on the array starting from offset.
    static void
    reverseSubArray(long[] array, int offset, int length)
    Reverse the length values on the array starting from offset.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • binarySearch

      public static int binarySearch(double[] array, double value, double tolerance)
      Return the index of value in array, or -1 if there is no such index. If there are several values that are within tolerance or less of value, this method will return the index of the closest value. In case of several values being as close ot value, 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
    • append

      public static <T> T[] append(T[] array, T added)
      Copy the given array and the added element into a new array of size array.length + 1.
      Type Parameters:
      T - type of the array elements
      Parameters:
      array - array to copy to the beginning of new returned array copy
      added - 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 the length values on the array starting from offset.
    • reverseSubArray

      public static void reverseSubArray(long[] array, int offset, int length)
      Reverse the length values on the array starting from offset.