public static < K1 , V1 , K2 , V2 , R extends Map < K2 , V2 > > R collect ( Map < K1 , V1 > map , final Function2 < ? super K1 , ? super V1 , Pair < K2 , V2 > > function , final R target ) { MapIterate . forEachKeyValue ( map , new Procedure2 < K1 , V1 > ( ) { public void value ( K1 key , V1 value ) { Pair < K2 , V2 > pair = function . value ( key , value ) ; target . put ( pair . getOne ( ) , pair . getTwo ( ) ) ; } } ) ; return target ; }
For each value of the map the function is evaluated with the key and value as the parameter . The results of these evaluations are collected into the target map .