Re: Don't be overawed by a C compiler.



hutch-- wrote:

> What is the purpose of introducing the STL template sort and the LIBC
> sort when there is no direct comparison with the exact algorithms ?

Both use the quick sort algorithm. Mayhaps a different implementation,
but I thought it was worth testing the speed of what you get from the
standard library.

> Is either the C or assembler source code available for either ? The whole
> purpose of the practice piece was to perform exact comparisons of the
> same algorithm.

The C++ source is available for STL the templates on any platform that
has STL support - for the simple reason that with just about every
C++ platform today, templates have to be available in source form.
They aren't a real joy to read, though.

The libc qsort routine is available in source form if you own a copy
of visual studio, but it's probably a copyright breach to redistribute
it here, so I won't.

Funny thing is that std::sort is 100% generic but still outperforms your
assembly implementation on all tested platforms. It will work for *any*
type that has a less-than operator defined, and for other types (or if
you want to sort on a different criteria), you can supply a binary
predicate yourself. The template nature makes sure it's fast (ie, no
superfluous "call comparefunc", as it will be inlined instead).

> Just as a note, the old C algo is broken in both its original and
> dumped forms. I cannot really vouch for code I did not design myself
> but the reverse order test in the practice piece did not show the
> broken results.

Why post broken code?


.



Relevant Pages

  • Re: one list, multiple sorting functions
    ... > I have an STL list (or any STL sequential data structure for that ... If you are using an implementation of the STL that does not support member ... template then you are stuck. ... a parameter to sort. ...
    (comp.lang.cpp)
  • Standard Template Library for Assembly
    ... I've just begun work on a Standard Template Library (STL) for assembly ... foreach b.forEachElementdo ...
    (alt.lang.asm)
  • Re: Standard Template Library for Assembly
    ... > I've just begun work on a Standard Template Library for assembly ... as influenced by the C++ STL. ...
    (alt.lang.asm)
  • Re: Programming languages in RLs
    ... but it is counterintuitive how many different fragments of the GCC STL pull ... The problem is that the following generally are worth the learning curve (most ... re-implementing for intentional POD (to get rid of the constructor, ... Template functions are type-checked macros that automatically evaluate each ...
    (rec.games.roguelike.development)
  • Re: Iterators redux
    ... allocating memory on the stack. ... we'd have an internal iterator, and it can't be on the stack. ... My example doesn't depend on templates or a template library. ... There is no inheritance or use of anything in the STL library. ...
    (comp.object)