Re: noop comparator for qsort
From: kevin.bagust (kevin.bagust_at_ntlworld.com)
Date: 11/14/04
- Next message: Robert Gamble: "Re: What does "void (*vector[])( )" means?"
- Previous message: Barry Schwarz: "Re: Modify Static Data Okay?"
- In reply to: Trent Buck: "noop comparator for qsort"
- Next in thread: Kurt Watzka: "Re: noop comparator for qsort"
- Reply: Kurt Watzka: "Re: noop comparator for qsort"
- Reply: Peter Nilsson: "Re: noop comparator for qsort"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 14 Nov 2004 19:06:38 GMT
In article <20041114191540.0a12ca75@harpo.marx>,
Trent Buck <NOSPAMfubarbaz@bigpond.com> wrote:
> The fourth argument is a comparator that returns `an integer less than,
> equal to, or greater than zero' depending on the ordering of its
> arguments.
> If I don't care about the order and simply want qsort() to run as
> quickly as possible, how should the comparator be defined?
How about comparing the pointers rather than the items pointed to? So
something like this:
int compare( void *x, void *y )
{
if ( x < y ) {
return -1;
}
else if ( y < x ) {
return 1;
}
else {
return 0;
}
}
Kevin Bagust.
- Next message: Robert Gamble: "Re: What does "void (*vector[])( )" means?"
- Previous message: Barry Schwarz: "Re: Modify Static Data Okay?"
- In reply to: Trent Buck: "noop comparator for qsort"
- Next in thread: Kurt Watzka: "Re: noop comparator for qsort"
- Reply: Kurt Watzka: "Re: noop comparator for qsort"
- Reply: Peter Nilsson: "Re: noop comparator for qsort"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|