Saturday 31 August 2013

How to Revert Key and Values of a HashMap?

How to Revert Key and Values of a HashMap?

I have created a HashMap<String,List<Integer>>. Now I want to create a
reverse HashMap<Integer,List<String>> by replacing the Key and Values from
the first map.
For Example,
Original HashMap: { A=[2,1], B=[1,3,4], C=[5], D=[3], E=[2,4] }
Reverted HashMap: { 1=[A,B], 2=[A,E], 3=[B,D], 4=[B,E], 5=[C] }

No comments:

Post a Comment