|So you have these conditions:
connect and disconnect
Seldom, single add / remove. Locking is no problem.
Periodically, all items must be accessed. Locking is a problem when updating requires a significant time.
Single? access in peridocally? short/long? intervals.
If locking is a problem depends on query frequency and number of items.
So it seems that only updating is critical. But as I understood you will update all items at once and know the max. number of items. Regardless of the choosen storage type, the first optimisation is reserving the required memory to avoid re-allocations and avoid members that use dynamic memory allocation like
So your requirements are:
- Inserting and deleting performance is not critical
- Iterating over all items is critical
- Accessing single items is not critical?
When using a map, use an
unordered_map because it satifies the above (fast iterating over all elements but slow iterating over a subset of the elements).
When using an array, list, or vector, you have to perform a find to access single elements (which is also there but hidden when using a map).
When using a pre-allocated C array you have to implement also functions to add and remove elements where adding is simple (append) but removing requires moving memory. But this will be probably the fastest option when iterating over all items.
But I don't think that the performance of a plain C array is much better than using a container iterator (note that you must use the iterator rather then using the
 operator because that result in a lookup with maps and include out of range checks with other container types).
You may implement different versions and benchmark them to see the differences. But a max. number of 10240 should be not critical.