[Interest] initialising a dictionary-type container instance with a static table?

Konstantin Shegunov kshegunov at gmail.com
Mon Jan 2 15:37:50 CET 2017


On Mon, Jan 2, 2017 at 4:27 PM, René J. V. Bertin <rjvbertin at gmail.com>
wrote:

> Still quite a sizeable population of users of older Mac OS X versions out
> there,
> who don't have proper C++11 support unless they do a libc++ conversion
> hack. And
> even then I'm not 100% sure that initialiser lists are available and/or
> work
> reliably.


Well, I don't work on mac, but if you need to stick to C++03 then your
options are rather limited (similar to the one in my first mail).


> Yes, true. Presuming the enum values assigned by the compiler and thus
> 0-based
> and incremented by 1.
>

Yes, I was referring to this exact use case.

I didn't read the algorithmic complexity section and wasn't encumbered with
> a
> particular amount of relevant background on the container classes either.
> Thus,
> the claim that "With QMap, the items are always sorted by key" made it seem
> somewhat more appropriate for a case where you get the keys in sorted order
> simply by copy/paste.
>

The remark is relevant for "larger" sets of data. For micro maps it
probably doesn't matter. Anyway, QMap is a balanced binary tree, so
inserting items sorted by key sequentially would cause it to rebalance
itself (i.e. insertion is with log(n) worst complexity).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170102/5674b198/attachment.html>


More information about the Interest mailing list