deps/include/hpat_sort.h
// Basic binary search to find the right position
Basic binary search to find the right position
Basic binary search to find the right position
static int64_t __hpat_binary_insertionsort_search(int64_t *comp_arr, const int64_t elem,const size_t size) {
  int64_t low, mid, high, pivot;
  low = 0;
  high = size - 1;
  mid = high >> 1;
  if (__hpat_sort_compare(elem, comp_arr[0]) < 0) {
    return 0;
  } else if (__hpat_sort_compare(elem, comp_arr[high]) > 0) {
    return high;
  }
  pivot = comp_arr[mid];
  while (1) {
    if (__hpat_sort_compare(elem, pivot) < 0) {
      if (mid - low <= 1) {
        return mid;
      }
      high = mid;
    } else {
      if (high - mid <= 1) {
        return mid + 1;
      }
      low = mid;
    }
    mid = low + ((high - low) >> 1);
    pivot = comp_arr[mid];
  }
}
static int64_t __hpat_binary_insertionsort_search ( int64_t * comp_arr , const int64_t elem , const size_t size ) { int64_t low , mid , high , pivot ; low = 0 ; high = size - 1 ; mid = high >> 1 ; if ( __hpat_sort_compare ( elem , comp_arr [ 0 ] ) < 0 ) { return 0 ; } else if ( __hpat_sort_compare ( elem , comp_arr [ high ] ) > 0 ) { return high ; } pivot = comp_arr [ mid ] ; while ( 1 ) { if ( __hpat_sort_compare ( elem , pivot ) < 0 ) { if ( mid - low <= 1 ) { return mid ; } high = mid ; } else { if ( high - mid <= 1 ) { return mid + 1 ; } low = mid ; } mid = low + ( ( high - low ) >> 1 ) ; pivot = comp_arr [ mid ] ; } }
Basic binary search to find the right position
Basic binary search to find the right position
// If it is less than low