Package es.upm.etsisi.cf4j.util
Class Search
- java.lang.Object
-
- es.upm.etsisi.cf4j.util.Search
-
public class Search extends Object
This class contains useful search methods.
-
-
Constructor Summary
Constructors Constructor Description Search()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int[]
findTopN(double[] values, int n)
Returns the indexes of the biggest n elements of the values array.static int
getIndex(int[] array, int value)
Gets efficiently the userIndex of an element in an array of integers
-
-
-
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 highestvalue
- 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 elementsn
- Number of elements to obtain- Returns:
- Indexes of values sorted by higher to lower
-
-