> On 2 Jan 2017, at 13:02, René J.V. Bertin <rjvber...@gmail.com> wrote:
> 
> Hi,
> 
> I must be overlooking or even forgetting something: is there a way to 
> initialise a QMap or QHash instance with a static table, say when you're 
> creating a fast lookup dictionary mapping enums or preprocessor tokens to a 
> QString?
> 
> That's information known a compile time so I was expecting to be able to 
> avoid adding each mapping explicitly with a sequence of
> 
> map[token] = "token";
> 
> statements. If that's indeed possible, the documentation doesn't really 
> showcase it.

It has operator<< and operator>> so I guess you could load it from a file.

It’s an interesting point though, if you have a fixed set of data then you 
could use a perfect hash and a perfect number of buckets.  There’s undoubtedly 
some other library which can do that.  I googled and found stuff like 
https://news.ycombinator.com/item?id=10745194 and 
http://stevehanov.ca/blog/index.php?id=119 which have more links to things like 
cmph and gperf.

But for tokenizing, maybe just use lex/flex?

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to