whats the fastest way to bucket sort pointers?

Started by
11 comments, last by Hodgman 12 years, 5 months ago
Use assembly language, stop screwing around, if you want speed, size, or both, come to the dark side @ asmcommunity.net
No we do not support malicious stuff, we are good people who help each other, and welcome novices and experts alike.
I was forced to program in c and c++ all this year, and i learned a few things, like, MSVC IS CRAP and I like codeblocks, and so on.
In C++, friends have access to your privates.
In ObjAsm, your members are exposed!
Advertisement
How were you profiling? Were you profiling a Debug or Release build? If iterating through a 12 element std::map was the most expensive thing in your "engine", then you mustn't be doing a lot of work elsewhere in your program.

Can you show us some code? Maybe you are making a minor mistake that ends up doing unnecessary work.

For small numbers of keys, a map has a lot of constant and hidden* overheads. It is only when the number of keys is large that you see the benefits. I agree with Hodgman, I think a sorted linear contiguous structure like std::vector<> would be much more efficient, and not too hard to code.

* [size="1"]Hidden overhead includes cost of cache misses and allocations, which is ignored by big O analysis.
A map (i.e. balanced binary tree) of vectors is totally overkill. Implementing it in assembly also wont help, as the inefficiency is in the algorithm / data-structure, not the implementation.

All you need is one [font="'Courier New"]std::vector[/font] plus [font="'Courier New"]std::sort[/font] (or a custom radix sort if you've got thousands of entities and want that little bit of extra speed).

This topic is closed to new replies.

Advertisement