simple int sort

This is a discussion on simple int sort within the C++ Programming forums, part of the General Programming Boards category; I suggested qsort simply because it would require no coding to make it b/c it is already made. If you ...

  1. #16
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    I suggested qsort simply because it would require no coding to make it b/c it is already made. If you have the time to write a sort, use radix i guess.

  2. #17
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    I actually think quicksort will be fine in this case. Z depth sorting is done once per frame so it's not necessarily the great bottleneck. If you were doing a sort once per polygon I'd have to insist on radix.

  3. #18
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    I'll probably eventually go with a radix sort (all of my values are positive, it's a 2d-hex tile game (simulated 3d )).

    I've profiled my original generic little bubble sort on my laptop (read: my low-end, p2 233mhz 4MB vidram system) and there was no noticeble slowdown.

    I say probably because this isn't an optimization that requires immediate attention, nor will it be much trouble to change it later (since it just involves changing one algorithm in a single function that will still take the same parameters and return the same result regardless of which sort I use).

    Thanks again for all the suggestions.
    Last edited by jdinger; 08-06-2002 at 04:01 PM.

  4. #19
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    Why not compare all the options? Here's a simple way to do it:

    Overload the algorithms with - say - 100 to 10,000 times normal load. Before each sort begins:

    start = clock();

    RadixSort();

    stop = clock();

    radixTime = (stop - start) / 1000;

    printf("Radix Sort Time Was %d Seconds.", radixTime);

    ...this would give you a good idea of which is superior...
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debug Error Really Quick Question
    By GCNDoug in forum C Programming
    Replies: 1
    Last Post: 04-23-2007, 12:05 PM
  2. Replies: 2
    Last Post: 03-24-2006, 07:36 PM
  3. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 11:36 AM
  4. Switch/case Problems (long code in post)
    By Wraithan in forum C++ Programming
    Replies: 2
    Last Post: 12-01-2005, 05:40 PM
  5. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21