Miscellaneous Container Templates

Is it possible to force table allocation?

Asked by Scott J Kolodzieski on 2012-11-05

I am experimenting with your container templates and have a question.

Is there a way to have the hash tables initialize when doing a reserve()? Although that ensures that the hash table is not resized again, it seems to be initialized on the first insertion, and that operation is taking a very long time, thus giving me extremely high latencies for the first insert. I would like to get the allocation/setup done on the reserve, thus ensuring a low latency on the first insert.

Question information

Language:
English Edit question
Status:
Answered
For:
MCT Edit question
Assignee:
No assignee Edit question
Last query:
2012-11-05
Last reply:
2012-11-07
Paul Pogonyshev (doublep) said : #1

No, there is no trivial way to do that currently (1.6).

The simplest workaround I can think of is to insert an element and immediately erase it. Tables are written in such a way they will not
drop the allocated memory on erasing the last element, they do it only if you call reserve() or a similar function afterwards.

Can you help with this problem?

Provide an answer of your own, or ask Scott J Kolodzieski for more information if necessary.

To post a message you must log in.