Mercurial > projects > dwt2
comparison 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 |
comparison
equal
deleted
inserted
replaced
26:f589fc20a5f9 | 27:1bf55a6eb092 |
---|---|
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 public Object get(String key){ | |
15 return super.get(key); | |
16 } | |
17 public Object put(String key, Object value){ | |
18 return super.put(key, value); | |
19 } | |
20 public Object put(Object key, String value){ | |
21 return super.put(key, value); | |
22 } | |
23 public Object put(String key, String value){ | |
24 return super.put(key, value); | |
25 } | |
26 public Object remove(String key){ | |
27 return super.remove(key); | |
28 } | |
29 | |
30 Object[Object] map; | |
31 | |
32 // The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. | |
33 public this(){ | |
34 } | |
35 public this(int initialCapacity){ | |
36 implMissing( __FILE__, __LINE__ ); | |
37 } | |
38 public this(int initialCapacity, float loadFactor){ | |
39 implMissing( __FILE__, __LINE__ ); | |
40 } | |
41 public this(Map t){ | |
42 implMissing( __FILE__, __LINE__ ); | |
43 } | |
44 | |
45 class ObjectEnumeration : Enumeration { | |
46 Object[] values; | |
47 int index = 0; | |
48 this( Object[] values ){ | |
49 this.values = values; | |
50 } | |
51 public bool hasMoreElements(){ | |
52 return index < values.length; | |
53 } | |
54 public Object nextElement(){ | |
55 Object res = values[index]; | |
56 index++; | |
57 return res; | |
58 } | |
59 } | |
60 | |
61 Enumeration elements(){ | |
62 return new ObjectEnumeration( map.values ); | |
63 } | |
64 Enumeration keys() { | |
65 return new ObjectEnumeration( map.keys ); | |
66 } | |
67 public synchronized void clear(){ | |
68 map = null; | |
69 } | |
70 public synchronized bool containsKey(Object key){ | |
71 if( auto v = key in map ){ | |
72 return true; | |
73 } | |
74 return false; | |
75 } | |
76 public synchronized bool containsKey(String key){ | |
77 return containsKey(stringcast(key)); | |
78 } | |
79 public synchronized bool containsValue(Object value){ | |
80 foreach( k, v; map ){ | |
81 if( v == value ){ | |
82 return true; | |
83 } | |
84 } | |
85 return false; | |
86 } | |
87 public Set entrySet(){ | |
88 implMissing( __FILE__, __LINE__ ); | |
89 return null; | |
90 } | |
91 public equals_t opEquals(Object o){ | |
92 implMissing( __FILE__, __LINE__ ); | |
93 return 0; | |
94 } | |
95 public synchronized Object get(Object key){ | |
96 if( auto v = key in map ){ | |
97 return *v; | |
98 } | |
99 return null; | |
100 } | |
101 public hash_t toHash(){ | |
102 implMissing( __FILE__, __LINE__ ); | |
103 return 0; | |
104 } | |
105 public synchronized bool isEmpty(){ | |
106 return map.length is 0; | |
107 } | |
108 public Set keySet(){ | |
109 implMissing( __FILE__, __LINE__ ); | |
110 return null; | |
111 } | |
112 public synchronized Object put(Object key, Object value){ | |
113 Object res = null; | |
114 if( auto v = key in map ){ | |
115 res = *v; | |
116 } | |
117 map[ key ] = value; | |
118 return res; | |
119 } | |
120 // public Object put(String key, Object value) | |
121 // public Object put(Object key, String value) | |
122 // public Object put(String key, String value) | |
123 public synchronized void putAll(Map t){ | |
124 implMissing( __FILE__, __LINE__ ); | |
125 } | |
126 public synchronized Object remove(Object key){ | |
127 implMissing( __FILE__, __LINE__ ); | |
128 return null; | |
129 } | |
130 // public Object remove(String key) | |
131 public synchronized int size(){ | |
132 return map.length; | |
133 } | |
134 public Collection values(){ | |
135 implMissing( __FILE__, __LINE__ ); | |
136 return null; | |
137 } | |
138 | |
139 // only for D | |
140 public int opApply (int delegate(ref Object value) dg){ | |
141 implMissing( __FILE__, __LINE__ ); | |
142 return 0; | |
143 } | |
144 public int opApply (int delegate(ref Object key, ref Object value) dg){ | |
145 implMissing( __FILE__, __LINE__ ); | |
146 return 0; | |
147 } | |
148 | |
149 } | |
150 |