By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,778 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,778 IT Pros & Developers. It's quick & easy.

[possibly OT] the comparison function in quicksort

P: n/a
Would it have been a good idea if the comparison function in quicksort
took three const void * parameters in, the third one for extra
information that might be required to compare the two objects, I think
the only way one can pass the information is by using global or static
variables.
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
de********@yahoo.com (Debashish Chakravarty) writes:
Would it have been a good idea if the comparison function in quicksort
You mean qsort().
took three const void * parameters in, the third one for extra
information that might be required to compare the two objects, I think
the only way one can pass the information is by using global or static
variables.


Yes, it would be a good idea. It is too bad that it doesn't. It
is sometimes difficult to effectively use qsort() and bsearch()
for this very reason. Most well-designed C abstract data type
extension libraries have such a mechanism for this very reason.
--
Peter Seebach on C99:
"[F]or the most part, features were added, not removed. This sounds
great until you try to carry a full-sized printout of the standard
around for a day."
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.