Article View: comp.std.c
Article #4957Re: Restrictions on qsort compare function?
From: Peter Curran
Date: Wed, 27 Mar 1996 15:31
Date: Wed, 27 Mar 1996 15:31
32 lines
2101 bytes
2101 bytes
[I posted a similar article yesterday, but it didn't seem to make it to the
'net. Appologize if this is redundant.]
On Fri, 22 Mar 1996 20:26:15 GMT in article <1996Mar22.202615.9926@sq.com>
msb@sq.com (Mark Brader) (Mark Brader) wrote:
># The function shall return an integer less than, equal to, or greater
># than zero if the first argument is considered to be respectively
># less than, equal to, or greater than the second.
>
>> > In other words, it must yield an ordering of the possible data values.
>> > This is only the case if
>> > 1. It is a pure function...
>> > 2. It is antisymmetric (I think that's the right word)...
>> > 3. If is transitive...
I have to disagree. While agreeing that what is stated here was roughly the
intent of the committee, the standard doesn't say it. (I don't really see the
In comparing two values 'a' and 'b', I could specify that I consider 'a' less
than 'b' when ((long) time()) produces an odd number, but 'a' greater than 'b'
otherwise. I can then write a comparison function that implements this
definition. I see nothing in this that would violate the standard, but it would
probably break many implementations of qsort(). I cannot imagine any use for
such a comparison definition, but it looks legal to me.
I think the standard needs to say that successive results generated by the
comparison function must be mutually consistent. I won't try to suggest wording
to capture that concept.
--
Peter Curran pcurran@inforamp.net
Technical Details
Message-ID:
<4jbmgo$qpl@sam.inforamp.net>Path:
arc1-ca.pugleaf.net!inforamp.net!usenetReferences:
<4iokop$h4p@lyra.csx.cam.ac.uk> <4iqjar$2m9@usenet.pa.dec.com> <1996Mar21.113301.2622@sq.com> <4it51b$ng8@usenet.pa.dec.com> <1996Mar22.202615.9926@sq.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!inforamp.net!usenet From: pcurran@inforamp.net (Peter Curran) Newsgroups: comp.std.c Subject: Re: Restrictions on qsort compare function? Date: Wed, 27 Mar 1996 15:31:46 GMT Organization: PSC Enterprises Message-ID: <4jbmgo$qpl@sam.inforamp.net> References: <4iokop$h4p@lyra.csx.cam.ac.uk> <4iqjar$2m9@usenet.pa.dec.com> <1996Mar21.113301.2622@sq.com> <4it51b$ng8@usenet.pa.dec.com> <1996Mar22.202615.9926@sq.com> Reply-To: pcurran@inforamp.net NNTP-Posting-Host: ts9-04.tor.inforamp.net X-Newsreader: Forte Free Agent 1.0.82