Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #27379

Re: callback function

From "Bill Cunningham" <billcun@suddenlink.net>
Newsgroups comp.lang.c
Subject Re: callback function
Date 2012-10-19 16:52 -0400
Organization Aioe.org NNTP Server
Message-ID <k5seis$icm$1@speranza.aioe.org> (permalink)
References (3 earlier) <k5q1b6$20r$1@speranza.aioe.org> <0.58b9a3605eafb94238da.20121019012305BST.874nlr48eu.fsf@bsb.me.uk> <k5q724$cn6$1@speranza.aioe.org> <e4p1889co1qctjdl35ne5fbsmpe9vskgps@4ax.com> <JMudne693991HBzNnZ2dnUVZ_oGdnZ2d@bestweb.net>

Show all headers | View raw


Kenneth Brody wrote:
> On 10/19/2012 1:30 AM, Barry Schwarz wrote:
>> On Thu, 18 Oct 2012 20:32:13 -0400, "Bill Cunningham"
>> <billcun@suddenlink.net> wrote:
>>
>>> Ben Bacarisse wrote:
>>>> "Bill Cunningham" <billcun@suddenlink.net> writes:
>>>>
>>>>> Ian Collins wrote:
>>>>>
>>>>>> The whole point of the parameters being const qualified is you
>>>>>> can't change values pointed to.
>>>>>
>>>>>      Then why
>>>>>
>>>>> return *pa-*pb;
> [...]
>> Because you are not interested in sorting the pointer values.  You
>> don't care if pa is >, ==, or < pb.
>>
>> You do want to sort the values the pointers point to.  The value pa
>> points to is *pa.  Ditto for *pb.  You do care if *pa is >, ++, or <
>> *pb.  Other than the possibility of overflow, *pa-*pb is a convenient
>> way of determining that relationship and returning the result in a
>> form qsort can use.
>
> Consider this:
>
> You have a bunch of bins, each a different color, full of toys.  You
> want to sort them by the age group for the toys in each.  You don't
> compare "green bin" to "blue bin", but rather you need to compare
> what's *in* the bins. That's (sort of) the equivalent of
> dereferencing a pointer -- you don't compare "pa" and "pb", but
> rather what's "in" them.
> Yes, it's a lame analogy, but I think it's about the right level of
> simplicity for the OP.

    That helps Kenneth thanks.

Bill

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-17 17:16 -0400
  Re: callback function John Gordon <gordon@panix.com> - 2012-10-17 21:36 +0000
    Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-17 17:44 -0400
      Re: callback function John Gordon <gordon@panix.com> - 2012-10-17 21:51 +0000
        Re: callback function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-18 00:11 +0100
        Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:37 -0400
          Re: callback function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-19 01:16 +0100
          Re: callback function Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-10-20 06:48 -0700
    Re: callback function Ian Collins <ian-news@hotmail.com> - 2012-10-18 10:45 +1300
      Re: callback function pete <pfiland@mindspring.com> - 2012-10-19 14:49 -0400
        Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 16:59 -0400
        Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 17:04 -0400
          Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-19 14:14 -0700
            Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 17:31 -0400
              Re: callback function Keith Thompson <kst-u@mib.org> - 2012-10-19 14:54 -0700
                Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 18:42 -0400
    Re: callback function James Kuyper <jameskuyper@verizon.net> - 2012-10-17 17:47 -0400
    Re: callback function tom st denis <tom@iahu.ca> - 2012-10-19 04:44 -0700
      Re: callback function James Kuyper <jameskuyper@verizon.net> - 2012-10-19 08:24 -0400
  Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-17 14:39 -0700
    Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-17 17:50 -0400
      Re: callback function Ian Collins <ian-news@hotmail.com> - 2012-10-18 11:00 +1300
        Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:20 -0400
        Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:24 -0400
          Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-18 22:30 -0700
          Re: callback function Ian Collins <ian-news@hotmail.com> - 2012-10-20 11:58 +1300
            Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 19:27 -0400
              Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 19:43 -0400
                Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-19 21:09 -0700
          Re: callback function Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-10-20 06:53 -0700
      Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-17 19:25 -0400
        Re: callback function Ian Collins <ian-news@hotmail.com> - 2012-10-18 13:34 +1300
          Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-17 20:41 -0400
            Re: callback function Ian Collins <ian-news@hotmail.com> - 2012-10-18 14:37 +1300
              Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:17 -0400
                Re: callback function Ian Collins <ian-news@hotmail.com> - 2012-10-20 11:54 +1300
              Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:54 -0400
                Re: callback function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-19 01:23 +0100
                Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 20:32 -0400
                Re: callback function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-19 02:43 +0100
                Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 16:56 -0400
                Re: callback function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-19 22:10 +0100
                Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-18 22:30 -0700
                Re: callback function Kenneth Brody <kenbrody@spamcop.net> - 2012-10-19 12:37 -0400
                Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 16:52 -0400
    Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-19 18:44 -0400
      Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-19 21:09 -0700
        Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-20 15:01 -0400
          Re: callback function Keith Thompson <kst-u@mib.org> - 2012-10-20 12:47 -0700
          Re: callback function Les Cargill <lcargill99@comcast.com> - 2012-10-20 14:51 -0500
          Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-20 14:39 -0700
            Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-20 19:06 -0400
              Re: callback function Barry Schwarz <schwarzb@dqel.com> - 2012-10-20 22:22 -0700
                Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-21 14:35 -0400
                Re: callback function Kenneth Brody <kenbrody@spamcop.net> - 2012-10-22 10:58 -0400
              Re: callback function Bill Cunningham <billcun@suddenlink.net> - 2012-10-24 17:28 -0700
          Re: callback function Ian Collins <ian-news@hotmail.com> - 2012-10-21 11:32 +1300
            Re: callback function Keith Thompson <kst-u@mib.org> - 2012-10-20 15:51 -0700
      Re: callback function Robert Miles <milesrf@Usenet-News.net> - 2012-11-25 22:39 -0600
  Re: callback function Keith Thompson <kst-u@mib.org> - 2012-10-17 17:51 -0700
    Re: callback function Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-10-18 20:34 +0300
    Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:15 -0400
      Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:27 -0400
      Re: callback function Keith Thompson <kst-u@mib.org> - 2012-10-18 15:47 -0700
        Re: callback function "Bill Cunningham" <billcun@suddenlink.net> - 2012-10-18 18:52 -0400
      Re: callback function blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2012-10-25 10:01 +0000
        Re: callback function Kenneth Brody <kenbrody@spamcop.net> - 2012-10-25 12:44 -0400
          Re: callback function blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2012-10-26 12:48 +0000
  Re: callback function Robert Miles <milesrf@Usenet-News.net> - 2012-11-25 22:13 -0600
    Re: callback function Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-26 03:42 -0800
    Re: callback function James Kuyper <jameskuyper@verizon.net> - 2012-11-26 06:59 -0500
    Re: callback function Keith Thompson <kst-u@mib.org> - 2012-11-26 23:03 -0800

csiph-web