mercredi 26 septembre 2018

Efficient way to map unique and duplicate value. Where key or value can be access

There are n no of string which need to map with another string.

Ex :     Bacardi_old - > Facundo 
         Smirnoff_old -> Pyotr 
         Seagram_old  -> Joseph
         This keep on ..... may be around 1000

There are some string which need to map with duplicate string.

Ex :     Bacardi_new  -> Facundo 
         Smirnoff_new -> Facundo 
         Seagram_new  -> Facundo 

Requirement: As Below case

case 1: when brand name input. Owner name as output.

input : Bacard_old
output: Facundo

case 2: When owner name input brand name as output.

input : Facundo
output : Bacardi_old, Bacardi_new ,Smirnoff_new ,Seagram_new 

My Approach:

1.I have a map as below :

std::map<std::string,std::vector<std::string>> Mymap;

2.Should i create two map one unique mapping and another for duplicate

std::map<std::string,std::string>Mymap
std::map<std::string,std::vector<std::string>>Mymap

Is the second option good than first in terms of all the aspect. Please suggest the best approach.

Note : I am stick with c++11.

Aucun commentaire:

Enregistrer un commentaire