public class DictionaryImp implements Dictionary { //Data private Function table; //Constructor public DictionaryImp(Function table) { this.table = table; } //Dictionary methods implementation public boolean containsKey(String key) { return table.containsKey(key); } public boolean containsValue(Object value) { throw new UnsupportedOperationException(); } public Object get(String key) { return table.get(key); } public Object put(String key,Object value) { return table.put(key,value); } public Object remove(String key) { return table.remove(key); } public boolean isEmpty() { return table.isEmpty(); } public boolean equals(Object obj) { throw new UnsupportedOperationException(); } public int size() { return table.size(); } public java.util.Iterator keys() { java.util.Comparator c = new EntryComparator(); SortedLinkedList temp = new SortedLinkedList(); //java.util.Set temp = new java.util.TreeSet(c); java.util.Iterator it = table.keys(); while(it.hasNext()) { String key = (String)it.next(); Entry m = new Entry(key); m.setValue(get(key)); temp.addInSortedList(c,m); //temp.add(m); } return new TableKeysIterator(temp.iterator()); } public java.util.Iterator values() { return table.values(); } public String toString() { String result = ""; java.util.Iterator it = keys(); while(it.hasNext()) { String key = (String)it.next(); Entry m = new Entry(key); m.setValue(get(key)); result = result + m + "\n"; } return result; } }