1 module java.util.Hashtable;
2 
3 import java.lang.all;
4 import java.util.Dictionary;
5 import java.util.Map;
6 import java.util.Enumeration;
7 import java.util.Collection;
8 import java.util.Set;
9 
10 // no nulls
11 // synchronized
12 class Hashtable : Dictionary, Map {
13 
14     override
15     public Object get(String key){
16         return super.get(key);
17     }
18     override
19     public Object put(String key, Object value){
20         return super.put(key, value);
21     }
22     override
23     public Object put(Object key, String value){
24         return super.put(key, value);
25     }
26     override
27     public Object put(String key, String value){
28         return super.put(key, value);
29     }
30     override
31     public Object remove(String key){
32         return super.remove(key);
33     }
34 
35     Object[Object] map;
36 
37     // The HashMap  class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls.
38     public this(){
39     }
40     public this(int initialCapacity){
41         implMissing( __FILE__, __LINE__ );
42     }
43     public this(int initialCapacity, float loadFactor){
44         implMissing( __FILE__, __LINE__ );
45     }
46     public this(Map t){
47         implMissing( __FILE__, __LINE__ );
48     }
49 
50     class ObjectEnumeration : Enumeration {
51         Object[] values;
52         int index = 0;
53         this( Object[] values ){
54             this.values = values;
55         }
56         public bool hasMoreElements(){
57             return index < values.length;
58         }
59         public Object nextElement(){
60             Object res = values[index];
61             index++;
62             return res;
63         }
64     }
65 
66     override
67     Enumeration  elements(){
68         return new ObjectEnumeration( map.values );
69     }
70     override
71     Enumeration        keys() {
72         return new ObjectEnumeration( map.keys );
73     }
74     public void clear(){
75         synchronized map = null;
76     }
77     public bool containsKey(Object key){
78         synchronized {
79             if( auto v = key in map ){
80                 return true;
81             }
82             return false;
83         }
84     }
85     public bool containsKey(String key){
86         synchronized return containsKey(stringcast(key));
87     }
88     public bool containsValue(Object value){
89         synchronized {
90              foreach( k, v; map ){
91                  if( v == value ){
92                      return true;
93                  }
94              }
95              return false;
96         }
97     }
98     public Set  entrySet(){
99         implMissing( __FILE__, __LINE__ );
100         return null;
101     }
102     override
103     public equals_t opEquals(Object o){
104         implMissing( __FILE__, __LINE__ );
105         return 0;
106     }
107     override
108     public Object get(Object key){
109         synchronized {
110             if( auto v = key in map ){
111                 return *v;
112             }
113             return null;
114         }
115     }
116     override
117     public hash_t toHash(){
118         implMissingSafe( __FILE__, __LINE__ );
119         return 0;
120     }
121     override
122     public bool isEmpty(){
123         synchronized return map.length is 0;
124     }
125     public Set    keySet(){
126         implMissing( __FILE__, __LINE__ );
127         return null;
128     }
129     override
130     public Object put(Object key, Object value){
131         synchronized {
132             Object res = null;
133             if( auto v = key in map ){
134                 res = *v;
135             }
136             map[ key ] = value;
137             return res;
138         }
139     }
140 //     public Object put(String key, Object value)
141 //     public Object put(Object key, String value)
142 //     public Object put(String key, String value)
143     public void   putAll(Map t){
144         synchronized
145         implMissing( __FILE__, __LINE__ );
146     }
147     override
148     public Object remove(Object key){
149         synchronized
150         implMissing( __FILE__, __LINE__ );
151         return null;
152     }
153 //     public Object remove(String key)
154     override
155     public int    size(){
156         synchronized return cast(int)/*64bit*/map.length;
157     }
158     public Collection values(){
159         implMissing( __FILE__, __LINE__ );
160         return null;
161     }
162 
163     // only for D
164     public int opApply (int delegate(ref Object value) dg){
165         implMissing( __FILE__, __LINE__ );
166         return 0;
167     }
168     public int opApply (int delegate(ref Object key, ref Object value) dg){
169         implMissing( __FILE__, __LINE__ );
170         return 0;
171     }
172 
173 }
174