dimanche 26 mars 2017

How to use each value of a std::set as a key of a map

Assume we have a map with int and set of strings

std::map < int , std::set<std::string> >  myString;

1=> "set1"
1=> "set2"
2=> "set1"
2=> "set2"

Now , Is it possible to make each uniq value of the above set as a map key
Roiughly , Data would be like

1=>
  set1=> "Hello"
  set1=> "Hey"
  set1=> "Wow"
1=>  
  set2=> "Hello"
  set2=> "Hey"
  set2=> "Wow"
2=>

  set1=> "Hello"
  set1=> "Hey"
  set1=> "Wow"
2=>  
  set2=> "Hello"
  set2=> "Hey"
  set2=> "Wow"

In plain words , i am trying to design a map

which has an integer key pointing to set of strings and each string again has multiple values , thus i thought of a set of string as a plain string to integer would overwrite the values and we would just have single final value

I dont think the below syntax would solve the issue

std::map < std::set<std::string>, std::string >  myString;

You advice would be really helpful , i am trying to break the bigger problem into short and will join all these sub problems

Sorry if my explanation is bad and confusing

Thanks Tejas

Aucun commentaire:

Enregistrer un commentaire