0
std::map< std::string ,std::string> mObj;
mObj["one"] = "hello";
mObj["two"] = "hello";
mObj["three"] ="hello;

How to get key when input is hello(this is dup )

  Ex 1 : when  refer to  mObj["one"] = "hello";

    input : hello

    output: one

  Ex 2: when refer to  mObj["two"] = "hello";

    input : hello

    output: two

  Ex 3 :when refer to     mObj["three"] ="hello;

   input : hello

    output : three

Is it good to make explicitly unique value to all the duplicate value during insert time. when input hello is received, i get the corresponding unique value (which was done internally) and get the correct key.

Please help to address this problem.

newcpp
  • 41
  • 4
  • Don't tag your question with both [c++] and [c]. – user202729 Aug 04 '18 at 03:32
  • You should not include 'thank' in posts. See this meta post: [Should 'Hi', 'thanks', taglines, and salutations be removed from posts?](https://meta.stackexchange.com/q/2950) – user202729 Aug 04 '18 at 03:34
  • @user202729 i think u r more good at finding the problem in question rather than look into solution. – newcpp Aug 04 '18 at 11:06
  • 1
    Note its not a duplicate question.the link to dup question is about unique value but here i am taking about duplicate value. Its totally different. i request you guys to read the question fully please – newcpp Aug 05 '18 at 00:02
  • Not clear enough. (1) Do you want all of the matching keys or any of them? (2) Do you need to support deletion from the map? – user202729 Aug 05 '18 at 00:11
  • (if deletion is not required then the method mentioned in the linked q/a worked. Otherwise it needs some minor modification) – user202729 Aug 05 '18 at 00:46
  • [c++ - seeking bidirectional map with non-unique keys or values - Stack Overflow](https://stackoverflow.com/questions/42356127/seeking-bidirectional-map-with-non-unique-keys-or-values) – user202729 Aug 05 '18 at 00:47
  • I have added some example. Please look at it and this is unique question not a dup. – newcpp Aug 05 '18 at 02:24
  • I stilll don't understand what you're trying to do. Assume you have a `mObj`, then do `mObj["one"] = "hello"; mObj["two"] = "hello";`, should looking up `"hello"` returns `"one"` or `"two"`? – user202729 Aug 05 '18 at 02:52

0 Answers0