In C:\jython21\jython_latest: "C:\Program Files\TortoiseCVS\cvs.exe" "-q" "--lf" "diff" "-u" "-r" "2.21" "org/python/core/PyDictionary.java" CVSROOT=:pserver:anonymous@cvs.sourceforge.net:/cvsroot/jython cvs diff: Empty password used - try 'cvs login' with a real password Index: org/python/core/PyDictionary.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyDictionary.java,v retrieving revision 2.21 diff -u -r2.21 PyDictionary.java --- org/python/core/PyDictionary.java 1 Nov 2002 14:57:49 -0000 2.21 +++ org/python/core/PyDictionary.java 20 May 2005 10:02:03 -0000 @@ -3,9 +3,19 @@ import java.util.Hashtable; import java.util.Enumeration; +/** + * Support for Map interface + * @author Mike Garcia + * @date April 1, 2005 + */ +import java.util.Map; +import java.util.Collection; +import java.util.Set; +import java.util.HashSet; +import java.util.Iterator; +import java.util.HashMap; +import java.util.ArrayList; - - class DictFuncs extends PyBuiltinFunctionSet { DictFuncs(String name, int index, int argcount) { @@ -33,7 +43,10 @@ case 6: return dict.keys(); case 7: - return dict.values(); + /** + * Changed values method name to _values for PyDictionary Map interface support + */ + return dict._values(); case 8: return dict.popitem(); default: @@ -78,12 +91,12 @@ - + /** * A builtin python dictionary. */ -public class PyDictionary extends PyObject implements ClassDictInit +public class PyDictionary extends PyObject implements ClassDictInit, Map { protected Hashtable table; @@ -103,16 +116,19 @@ * Create an empty dictionary. */ public PyDictionary() { - this(new Hashtable()); + this(new Hashtable()); } - /** - * Create an new dictionary which is based on the hashtable. - * @param t the hashtable used. The supplied hashtable is used as - * is and must only contain PyObject key:value pairs. - */ + /** + * Create an new dictionary which is based on the hashtable. + * @param t the hashtable used. The supplied hashtable is used as + * is and must only contain PyObject key:value pairs. + */ public PyDictionary(Hashtable t) { - table = t; + table = t; + this.keySet = table.keySet(); + this.values = table.values(); + this.entrySet = table.entrySet(); } /** @@ -136,7 +152,10 @@ dict.__setitem__("clear", new DictFuncs("clear", 4, 0)); dict.__setitem__("items", new DictFuncs("items", 5, 0)); dict.__setitem__("keys", new DictFuncs("keys", 6, 0)); - dict.__setitem__("values", new DictFuncs("values", 7, 0)); + /** + * Updated table to point to orignial values method now called _values + */ + dict.__setitem__("_values", new DictFuncs("_values", 7, 0)); dict.__setitem__("popitem", new DictFuncs("popitem", 8, 0)); dict.__setitem__("__cmp__", new DictFuncs("__cmp__", 11, 1)); dict.__setitem__("has_key", new DictFuncs("has_key", 12, 1)); @@ -208,11 +227,24 @@ StringBuffer buf = new StringBuffer("{"); for(int i=0; i