April 05
Prde. Ismael H. F. Santos -  ismael@tecgraf.puc-rio.br                                                          2
Exemplo MultiMap – Anagram groups
nMap cujos Valores sao List
npublic class Anagrams {
n   public static void main(String[] args) {
n      int minGroupSize = Integer.parseInt(args[1]);
n      // Read words from file and put into a simulated multimap
n      Map<String, List<String>> m = new HashMap<String, List<String>>();
n      try {
n         Scanner s = new Scanner(new File(args[0]));
n         while (s.hasNext()) {
n             String word = s.next(); String alpha = alphabetize(word);
n              List<String> l = m.get(alpha);
n              if ( l == null ) m.put(alpha, l=new ArrayList<String>());
n              l.add(word);
n           }
n      } catch (IOException e) {
n          System.err.println(e); System.exit(1);
n      }