• Glebz (unregistered) in reply to ferrengi

    C'mon, he's been paid by the lines of code. [;)]

  • (cs) in reply to Glebz

    I implemented the Quadrasort in C++ to do some profiling. The strategy employed reduces the number of necessary swaps considerably. The last loop performs no swaps at all; it's just for fun.

    I would sort all my dates like this from now on, but the idea is probably patented.

    return 0;

  • Tom (unregistered) in reply to kipthegreat

    What do you mean in Java 1.5 ? This code has been valid since at least Java 1.2

    String [] l_names = new String [ l_namesCollection.size() ];
    l_names = (String []) l_namesCollection.toArray( l_names )


    However I'm not surprised... I've seen the for loop dumping into an array so many times before. People don't bother reading the docs or experimenting.

  • Luap Mutat (unregistered)

    I dunno, I think this code is brilliant. I could never write something like this. I just hope I never have to have anything to do with the author.

  • Ben B (unregistered)

    Last!

    sorry, I was just so excited to see there was a sh*t load of comments here already.

  • Cam (unregistered) in reply to RevMike

    These comments are probably too old and no one will read this, but isn't TankerJoes code incorrect? Its less byte code because it isn't equivalent. Both waste unused memory.

    whoisfred:
    String[] a = (String[]) c.toArray(new String[c.size]);
    TankerJoe:
    String[] a = new String[c.size()];
    c.toArray(a);
    RevMike:
    TankerJoe's two line method is slightly faster. It evaluates to...

    whoisfred assigns the resulting String[] while TankerJoe doesn't store the result.

    The List.toArray(Object[] arg) method does not populate the array parameter, it merely uses the runtime type for the result.

    String[] a = (String[]) list.toArray(new String[0]);

    ... all this pedantry is pretty unhealthy really.

  • ichr@mm (unregistered)

    I am sorry, but i think that is not fast enough, it has order of n2

  • hjk (unregistered) in reply to TankerJoe
    TankerJoe:
    This all makes so much sense!!!!  Brillant!!!  I fully expect a new API to result from this.  It should implement:

    Name of sort         File name pattern ==========       ============ UnarySort          -  YYYY.ext BinarySort         -   YYYYMM.ext    (who cares if this name is already taken.) TernarySort       -   YYYYMMDD.ext QuadraSort       -   YYYYMMDDHH.ext QuinarySort      -    YYYYMMDDHHMM.ext SenarySort        -    YYYYMMDDHHMMSS.ext SeptenarySort   -    YYYYMMDDHHMMSSMMM.ext OctalSort          -    YYYYMMDDHHMMSSMMMNNN.ext

    Bah!

  • (cs) in reply to Mikademus
    Mikademus:
    Now that's a lot of code for doing really very little...
    Some people are alays geting paid for line of coed. In such circumstance, it is always better to put in more lines of code.

Leave a comment on “The Quadrasort”

Log In or post as a guest

Replying to comment #:

« Return to Article