Is it normal practice or very bad to nest maps several levels?
// name property // name singal // interval of Ranges // values
typedef std::map<std::string, std::map<std::string, std::map<RangeSignalValue, std::string > > > sgHashSignals;
I've certainly done this. However, I'd break down the definition into digestible chunks:
typedef std::map<RangeSignalValue, std::string> RangeIntervalMap;
typedef std::map<std::string, RangeIntervalMap> NameSignalMap;
typedef std::map<std::string, NameSignalMap> NamePropertyMap;
If it makes sense in the context you're working in then I don't see any problems, other than it might be hard to read. Might it be possible to use typedef to make some of these nested maps easier to understand?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With