Class Search


  • public class Search
    extends Object
    This class contains useful search methods.
    • Constructor Detail

      • Search

        public Search()
    • Method Detail

      • getIndex

        public static int getIndex​(int[] array,
                                   int value)
        Gets efficiently the userIndex of an element in an array of integers
        Parameters:
        array - Array of integers sorted from lowest to highest
        value - Value which calculates the position
        Returns:
        Index of the item or -1 if not found
      • findTopN

        public static int[] findTopN​(double[] values,
                                     int n)
        Returns the indexes of the biggest n elements of the values array. If the values arrays is smaller than N, the returned array is completed with -1. The NaN values are ignored.
        Parameters:
        values - Array to search its top n elements
        n - Number of elements to obtain
        Returns:
        Indexes of values sorted by higher to lower