package yi.ds;

import java.util.*;

/**
 * KeyToListHashMap implements a specific HashMap whose value is LinkedList.
 */

public class KeyToListHashMap extends HashMap {

  public void addToList(Object key, Object new_element) {
    LinkedList list = (LinkedList)get(key);
    if (list == null) {  // if there is no corresponding LinkedList yet
      list = new LinkedList();
    }
    list.add(new_element);
    put(key, list);
  }

  public int size(Object key) {
    LinkedList list = (LinkedList)get(key);
    if (list == null) {  // if there is no corresponding LinkedList yet
      return 0;
    }
    return list.size();

  }

  public static void main(String[] args) {
    KeyToListHashMap keyToListHashMap1 = new KeyToListHashMap();
  }

}