Thread: simple int sort

  1. #16
    ¡Amo fútbol!
    Join Date
    Dec 2001
    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
    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
    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
    Waterloo, Texas
    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();


    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...
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
        return std::pow
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;

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, 08:36 PM
  3. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 12:36 PM
  4. Switch/case Problems (long code in post)
    By Wraithan in forum C++ Programming
    Replies: 2
    Last Post: 12-01-2005, 06:40 PM
  5. Binary Search Trees Part III
    By Prelude in forum A Brief History of
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM