[possibly OT] the comparison function in quicksort

  • Thread starter Debashish Chakravarty
  • Start date
D

Debashish Chakravarty

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.
 
B

Ben Pfaff

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top