public static < K , V > PairedMapValues < V > zipValues ( final Map < K , V > left , final Map < K , V > right ) { checkNotNull ( left ) ; checkNotNull ( right ) ; final ImmutableList . Builder < ZipPair < V , V > > pairedValues = ImmutableList . builder ( ) ; final ImmutableList . Builder < V > leftOnly = ImmutableList . builder ( ) ; final ImmutableList . Builder < V > rightOnly = ImmutableList . builder ( ) ; for ( final Map . Entry < K , V > leftEntry : left . entrySet ( ) ) { final K key = leftEntry . getKey ( ) ; if ( right . containsKey ( key ) ) { pairedValues . add ( ZipPair . from ( leftEntry . getValue ( ) , right . get ( key ) ) ) ; } else { leftOnly . add ( leftEntry . getValue ( ) ) ; } } for ( final Map . Entry < K , V > rightEntry : right . entrySet ( ) ) { if ( ! left . containsKey ( rightEntry . getKey ( ) ) ) { rightOnly . add ( rightEntry . getValue ( ) ) ; } } return new PairedMapValues < V > ( pairedValues . build ( ) , leftOnly . build ( ) , rightOnly . build ( ) ) ; }
Pairs up the values of a map by their common keys .