public static < K , V > void reverse ( Map < K , V > source , Map < V , K > target ) { Iterator < K > i = source . keySet ( ) . iterator ( ) ; while ( i . hasNext ( ) ) { K key = i . next ( ) ; V value = source . get ( key ) ; target . put ( value , key ) ; } }
Take key and value pairs from source and create map from value to key in target .