lammps-master/src/mergesort.h
static void do_merge(int *idx, int *buf, int llo, int lhi, int rlo, int rhi,
                     void *ptr, int (*comp)(int, int, void *))
{
  int i = llo;
  int l = llo;
  int r = rlo;
  while ((l < lhi) && (r < rhi)) {
    if ((*comp)(buf[l],buf[r],ptr) < 0)
      idx[i++] = buf[l++];
    else idx[i++] = buf[r++];
  }

  while (l < lhi) idx[i++] = buf[l++];
  while (r < rhi) idx[i++] = buf[r++];
}
// part 2. merge two sublists
part 2. merge two sublists
part 2 . merge two sublists
static void do_merge(int *idx, int *buf, int llo, int lhi, int rlo, int rhi,
                     void *ptr, int (*comp)(int, int, void *))
{
  int i = llo;
  int l = llo;
  int r = rlo;
  while ((l < lhi) && (r < rhi)) {
    if ((*comp)(buf[l],buf[r],ptr) < 0)
      idx[i++] = buf[l++];
    else idx[i++] = buf[r++];
  }
  while (l < lhi) idx[i++] = buf[l++];
  while (r < rhi) idx[i++] = buf[r++];
}
static void do_merge ( int * idx , int * buf , int llo , int lhi , int rlo , int rhi , void * ptr , int ( * comp ) ( int , int , void * ) ) { int i = llo ; int l = llo ; int r = rlo ; while ( ( l < lhi ) && ( r < rhi ) ) { if ( ( * comp ) ( buf [ l ] , buf [ r ] , ptr ) < 0 ) idx [ i ++ ] = buf [ l ++ ] ; else idx [ i ++ ] = buf [ r ++ ] ; } while ( l < lhi ) idx [ i ++ ] = buf [ l ++ ] ; while ( r < rhi ) idx [ i ++ ] = buf [ r ++ ] ; }
part 2. merge two sublists
part 2 . merge two sublists