lundi 23 avril 2018

Initialize class static map with 60K+ entries

I have a class like this:

class AntennaController
{
    public:
        static map<uint16_t, uint64_t> channel_to_freq;
        static map<uint64_t, uint16_t> freq_to_channel;
};

These two maps convert transmit frequencies to channels, and vice versa (i.e. 140000000 -> 4, 4 -> 140000000). There are 65536 different channels.

So my question is: is there a way to initialize these static members without manually listing out all 65536 key-value pairs for each map (i.e. with a for loop)?

And if I don't use a static map so that I can initialize it in the constructor, won't every single instance have its own copy?

Aucun commentaire:

Enregistrer un commentaire