Class LongBinarySearch


  • public class LongBinarySearch
    extends java.lang.Object
    Binary search for primitive type long.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int binarySearch​(ILongList list, long key, int lower, int upper)
      Searches the specified list for the specified object using the binary search algorithm.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LongBinarySearch

        public LongBinarySearch()
    • Method Detail

      • binarySearch

        public static int binarySearch​(ILongList list,
                                       long key,
                                       int lower,
                                       int upper)
        Searches the specified list for the specified object using the binary search algorithm. The list must be sorted into ascending order according to the specified comparator (as by the Collections.sort(List, Comparator) method), prior to making this call. If it is not sorted, the results are undefined.

        This method runs in log(n) time on random-access lists, which offer near-constant-time access to each list element.

        Parameters:
        list - the list to be searched.
        key - the value to be searched for.
        lower - lower bound of range to search
        upper - upper bound of range to search
        Returns:
        the index of the search key, if it is contained in the list; otherwise, (-(insertion point) - 1).