I have a map. I want to flip the key-value so that it not becomes map. So basically the value of the first map becomes the key of the second map. How do i do this?
Example map:
1 - 1.0
2 - 2.0
After flip
1.0 - 1
2.0 - 2
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The most straightforward way (that I know of) is to create a new map with the types flipped, and iterate the old one and add each key-value pair in reverse.
For example,