Results 1 to 14 of 14

Thread: Sorting using qSort(), - if QList contains POINTERS

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Posts
    157
    Qt products
    Qt3 Qt4
    Thanks
    12
    Thanked 1 Time in 1 Post

    Default Re: Sorting using qSort(), - if QList contains POINTERS

    Quote Originally Posted by jpn View Post
    Indeed, as QListIterator docs state:

    Also, may I ask what's the point of allocating doubles on the heap? Notice that QList is an implicitly shared class.

    Thanks for you information.
    yes you are right. There is no need for <double*>.
    But it was just an example.


    I have tried with QMutableListIterator . its working perfectly
    thanks

  2. #2
    Join Date
    Mar 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Sorting using qSort(), - if QList contains POINTERS


  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,332
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    317
    Thanked 871 Times in 858 Posts

    Default Re: Sorting using qSort(), - if QList contains POINTERS

    I am sure that 6 years ago, your advice would have been useful. Meanwhile, the OP's original project was canceled, the company went under, and he's had 4 different jobs since then.

    Functors are nice, but when all you need is a simple static function that takes two pointers to double as arguments and returns a bool, adding all that overhead is overkill. And will the person who inherits this code take a look and ask, "Why the heck did they use functors when a static function would have worked just as well? Must be reading too many advanced C++ books".

    Been there, done that. Functors have their uses and many C++ generic programming template constructs could not be implemented without them. Sorting a list of pointers by the value of the pointed-to instance isn't one of them.
    Last edited by d_stranz; 18th August 2013 at 19:00.

Similar Threads

  1. QList of pointers
    By Farcaller in forum Newbie
    Replies: 4
    Last Post: 24th January 2006, 16:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.