Mercurial > projects > dwt2
diff base/src/java/util/Hashtable.d @ 27:1bf55a6eb092
Renamed java tree to base
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 21 Mar 2009 11:33:57 +0100 |
parents | java/src/java/util/Hashtable.d@9b96950f2c3c |
children | 9f4c18c268b2 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/java/util/Hashtable.d Sat Mar 21 11:33:57 2009 +0100 @@ -0,0 +1,150 @@ +module java.util.Hashtable; + +import java.lang.all; +import java.util.Dictionary; +import java.util.Map; +import java.util.Enumeration; +import java.util.Collection; +import java.util.Set; + +// no nulls +// synchronized +class Hashtable : Dictionary, Map { + + public Object get(String key){ + return super.get(key); + } + public Object put(String key, Object value){ + return super.put(key, value); + } + public Object put(Object key, String value){ + return super.put(key, value); + } + public Object put(String key, String value){ + return super.put(key, value); + } + public Object remove(String key){ + return super.remove(key); + } + + Object[Object] map; + + // The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. + public this(){ + } + public this(int initialCapacity){ + implMissing( __FILE__, __LINE__ ); + } + public this(int initialCapacity, float loadFactor){ + implMissing( __FILE__, __LINE__ ); + } + public this(Map t){ + implMissing( __FILE__, __LINE__ ); + } + + class ObjectEnumeration : Enumeration { + Object[] values; + int index = 0; + this( Object[] values ){ + this.values = values; + } + public bool hasMoreElements(){ + return index < values.length; + } + public Object nextElement(){ + Object res = values[index]; + index++; + return res; + } + } + + Enumeration elements(){ + return new ObjectEnumeration( map.values ); + } + Enumeration keys() { + return new ObjectEnumeration( map.keys ); + } + public synchronized void clear(){ + map = null; + } + public synchronized bool containsKey(Object key){ + if( auto v = key in map ){ + return true; + } + return false; + } + public synchronized bool containsKey(String key){ + return containsKey(stringcast(key)); + } + public synchronized bool containsValue(Object value){ + foreach( k, v; map ){ + if( v == value ){ + return true; + } + } + return false; + } + public Set entrySet(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public equals_t opEquals(Object o){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public synchronized Object get(Object key){ + if( auto v = key in map ){ + return *v; + } + return null; + } + public hash_t toHash(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public synchronized bool isEmpty(){ + return map.length is 0; + } + public Set keySet(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public synchronized Object put(Object key, Object value){ + Object res = null; + if( auto v = key in map ){ + res = *v; + } + map[ key ] = value; + return res; + } +// public Object put(String key, Object value) +// public Object put(Object key, String value) +// public Object put(String key, String value) + public synchronized void putAll(Map t){ + implMissing( __FILE__, __LINE__ ); + } + public synchronized Object remove(Object key){ + implMissing( __FILE__, __LINE__ ); + return null; + } +// public Object remove(String key) + public synchronized int size(){ + return map.length; + } + public Collection values(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + // only for D + public int opApply (int delegate(ref Object value) dg){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public int opApply (int delegate(ref Object key, ref Object value) dg){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + +} +