5 public class ChainHashMap<K,V> extends AbstractMap<K,V> {
6 private ChainHashMap<K,V> parent;
7 private HashMap<K,V> table;
9 public ChainHashMap() {
10 table=new HashMap<K,V>();
13 public ChainHashMap<K,V> makeChild() {
14 ChainHashMap<K,V> chm=new ChainHashMap<K,V>();
19 public ChainHashMap<K,V> getParent() {
23 public V put(K key, V value) {
24 return table.put(key, value);
27 public V get(Object o) {
29 if (table.containsKey(key))
30 return table.get(key);
31 else if (parent!=null)
32 return parent.get(key);
37 public boolean containsKey(Object o) {
39 if (table.containsKey(key))
41 else if (parent!=null)
42 return parent.containsKey(key);
47 public Set<Map.Entry<K,V>> entrySet() {
48 throw new Error("ChainHashMap does not support entrySet");