Package org.jf.util

Class LinearSearch

java.lang.Object
org.jf.util.LinearSearch

public class LinearSearch extends Object
  • 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 search
      comparator - The comparator to use
      key - The key to search for
      initialGuess - 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