Package org.jf.util
Class LinearSearch
java.lang.Object
org.jf.util.LinearSearch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> intlinearSearch(List<? extends T> list, Comparator<T> comparator, T key, int initialGuess) Performs a linear search in a sorted list for key, starting at initialGuess
-
Constructor Details
-
LinearSearch
public LinearSearch()
-
-
Method Details
-
linearSearch
public static <T> int linearSearch(List<? extends T> list, Comparator<T> comparator, T key, int initialGuess) Performs a linear search in a sorted list for key, starting at initialGuess- Parameters:
list- The sorted list to searchcomparator- The comparator to usekey- The key to search forinitialGuess- An initial guess of the location.- Returns:
- If found, the index of the item. If not found, -return + 1 is the index at which the item would be inserted
-