[Interest] QMap operator<() overload.

Koehne Kai Kai.Koehne at theqtcompany.com
Wed Feb 25 14:19:30 CET 2015



> -----Original Message-----
> From: interest-bounces+kai.koehne=theqtcompany.com at qt-project.org
> [...]
> Could you elaborate a little on your comment, and on for which use cases
> QMap might not be the "right" abstraction?
> 
> I've always thought that maps (and hash-maps, e.g. std::unordered_map)
> were the right tool when you want to look up a value using a key.  Are there
> pitfalls in this use case?

As usual with performance, it highly depends on how you use it ... Anyhow, this was recently discussed on the development at qt-project.org mailing ist:

http://permalink.gmane.org/gmane.comp.lib.qt.devel/20044

> Or are there other use cases where you often see people using maps when
> something else would be more efficient?

Citing from the above: 

" In the vast majority of cases, a sorted vector is much faster, due to locality-of-reference. A RB-tree is optimized for wildly mixing insertions, lookups, and removals. When you can batch updates and separate them from lookups, time-wise, then a sorted vector is usually preferrable."

If in doubt (and it matters), measure :)

Regards

Kai



More information about the Interest mailing list