import java.util.Iterator; public abstract class AbstractMap implements Map206 { protected class Entry implements MEntry { private final L key; private final W value; public L getKey() { return key; } public W getValue() { return value; } public Entry(L k, W v) { this.key=k; this.value=v; } } @Override public boolean isEmpty() { return size()==0; } private class KeyIterator implements Iterator { private Iterator> entries = entrySet().iterator(); public boolean hasNext() { return entries.hasNext(); } public K next() { return entries.next().getKey(); } public void remove(L key) { throw new UnsupportedOperationException(); } } private class KeyIterable implements Iterable { public Iterator iterator() { return new KeyIterator(); } } @Override public Iterable keySet() { return new KeyIterable(); } private class ValueIterator implements Iterator { private Iterator> entries = entrySet().iterator(); public boolean hasNext() { return entries.hasNext(); } public V next() { return entries.next().getValue(); } public void remove(L key) { throw new UnsupportedOperationException(); } } private class ValueIterable implements Iterable { public Iterator iterator() { return new ValueIterator(); } } @Override public Iterable values() { return new ValueIterable(); } }