mardi 14 février 2023

How to store multi-dimensional key-value pair?

I have the below sequence of data to be stored into C++ container.

`Type1 -> Channel 0 -> Data1 -> Value
                   -> Data2 -> Value
                   -> Data3 -> Value
         Channel 1 -> Data1 -> Value
                   -> Data2 -> Value
                   -> Data3 -> Value
         Channel 2 -> Data1 -> Value
                   -> Data2 -> Value
                   -> Data3 -> Value
Type2 -> Channel 0 -> Data1 -> Value
                   -> Data2 -> Value
Type3 -> Channel 0 -> Data1 -> Value
                   -> Data2 -> Value
         Channel 1 -> Data1 -> Value
                   -> Data2 -> Value`

What is the best way to store in a container. We use C++14.

Thanks in advance !!

I have tried the below map:

std::map<std::string,std::map<int,std::map<std::string, int>>> DataMap;

Is there any optimized way to do this?

Aucun commentaire:

Enregistrer un commentaire