carrays.h
static inline bool gca_is_sorted(void *base, size_t nel, size_t es,
                                 int (*compar)(const void *_a, const void *_b,
                                               void *_arg),
                                 void *arg)
{
  char *b = (char*)base, *end = b+es*nel, *ptr;
  for(ptr = b; ptr+es < end; ptr += es)
    if(compar(ptr, ptr+es, arg) > 0)
      return false;
  return true;
}
//
// Check if an array is sorted
//
Check if an array is sorted
Check if an array is sorted
static inline bool gca_is_sorted(void *base, size_t nel, size_t es,
                                 int (*compar)(const void *_a, const void *_b,
                                               void *_arg),
                                 void *arg)
{
  char *b = (char*)base, *end = b+es*nel, *ptr;
  for(ptr = b; ptr+es < end; ptr += es)
    if(compar(ptr, ptr+es, arg) > 0)
      return false;
  return true;
}
static inline bool gca_is_sorted ( void * base , size_t nel , size_t es , int ( * compar ) ( const void * _a , const void * _b , void * _arg ) , void * arg ) { char * b = ( char * ) base , * end = b + es * nel , * ptr ; for ( ptr = b ; ptr + es < end ; ptr += es ) if ( compar ( ptr , ptr + es , arg ) > 0 ) return false ; return true ; }
Check if an array is sorted
Check if an array is sorted