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

Konstantin Shegunov kshegunov at gmail.com
Mon Jan 2 15:14:19 CET 2017


On Mon, Jan 2, 2017 at 4:02 PM, René J.V. Bertin <rjvbertin at gmail.com>
wrote:
>
> QMap<MyEnum,QString> dict = { {Enum1, QStringLiteral("Enum1")}, {Enum2,
> QStringLiteral("Enum2")} };
>

As a side note, if your enums are sequential and starting from 0, as most
are, my advice is not to use QMap (a static array should serve you
perfectly fine). It would mean the binary tree to be degenerate, and
ultimately you'd get a rebalancing with each insert.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170102/6f31f9c9/attachment.html>


More information about the Interest mailing list