Java Map Reverse reverseMapping(Map value2keys, Map map)

Here you can find the source of reverseMapping(Map value2keys, Map map)

Description

reverse Mapping

License

Open Source License

Declaration

static public void reverseMapping(Map value2keys, Map map) 

Method Source Code

//package com.java2s;
/*/*from w w w  .  j ava2s . c  om*/
 RoadRunner - an automatic wrapper generation system for Web data sources
 Copyright (C) 2003  Valter Crescenzi - crescenz@dia.uniroma3.it
    
 This program is  free software;  you can  redistribute it and/or
 modify it  under the terms  of the GNU General Public License as
 published by  the Free Software Foundation;  either version 2 of
 the License, or (at your option) any later version.
    
 This program is distributed in the hope that it  will be useful,
 but  WITHOUT ANY WARRANTY;  without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 General Public License for more details.
    
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the:
    
 Free Software Foundation, Inc.,
 59 Temple Place, Suite 330,
 Boston, MA 02111-1307 USA
    
 ----
    
 RoadRunner - un sistema per la generazione automatica di wrapper su sorgenti Web
 Copyright (C) 2003  Valter Crescenzi - crescenz@dia.uniroma3.it
    
 Questo  programma  software libero;   lecito redistribuirlo  o
 modificarlo secondo i termini della Licenza Pubblica Generica GNU
 come ? pubblicata dalla Free Software Foundation; o la versione 2
 della licenza o (a propria scelta) una versione successiva.
    
 Questo programma   distribuito nella speranza che sia  utile, ma
 SENZA  ALCUNA GARANZIA;  senza neppure la  garanzia implicita  di
 NEGOZIABILIT?  o di  APPLICABILIT? PER  UN PARTICOLARE  SCOPO. Si
 veda la Licenza Pubblica Generica GNU per avere maggiori dettagli.
    
 Questo  programma deve  essere  distribuito assieme  ad una copia
 della Licenza Pubblica Generica GNU; in caso contrario, se ne pu
 ottenere  una scrivendo  alla:
    
 Free  Software Foundation, Inc.,
 59 Temple Place, Suite 330,
 Boston, MA 02111-1307 USA
    
*/

import java.util.*;

public class Main {
    static public void reverseMapping(Map value2keys, Map map) {
        Iterator it = map.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();
            Object value = entry.getValue();
            Object key = entry.getKey();
            List keys = (List) value2keys.get(value);
            if (keys == null)
                keys = new LinkedList();
            keys.add(key);
            value2keys.put(value, keys);
        }
    }
}

Related

  1. reverseMap(Map map)
  2. reverseMap(Map origMap)
  3. reverseMap(Map map)
  4. reverseMap(Map keyIdMap, Map keyValueMap)
  5. reverseMapLookup(Map map, V value)
  6. reverseMapping(Map map)
  7. sort(Map> dataNodes, boolean reverse)
  8. sort(Map source, boolean reverse)
  9. sortByUsedSpace(Map> dataNodes, boolean reverse)