// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.*;

public class HashList {
   private HashMap hm;
   public HashList() {
      hm = new HashMap();
   }
   public void add(String word, String url) {
      ArrayList al = (ArrayList)hm.get(word);
      if(al == null) {
         al = new ArrayList();
         hm.put(word, al);
      }
      al.add(url);
   }
   public Object[] get(String word) {
      ArrayList al = (ArrayList)hm.get(word);
      if(al == null) {
         return null;
      } else {
         return al.toArray();
      }
   }
   public static void main(String[] args) {
      HashList hl = new HashList();
      hl.add("a", "http://www.1.dk/");
      hl.add("a", "http://www.2.dk/");
      hl.add("b", "http://www.2.dk/");
      hl.add("a", "http://www.3.dk/");
      hl.add("b", "http://www.3.dk/");
      hl.add("c", "http://www.3.dk/");
      Object[] hits = hl.get("b");
      for(int i = 0; i < hits.length; i++) {
         System.out.println((String)hits[i]);
      }
   }
}
