comparison java/src/java/util/HashSet.d @ 10:eb8ff453285d

Added java.util collection classes.
author Frank Benoit <benoit@tionex.de>
date Fri, 13 Mar 2009 16:57:07 +0100
parents
children 9b96950f2c3c
comparison
equal deleted inserted replaced
9:950d84783eac 10:eb8ff453285d
1 module java.util.HashSet;
2
3 import java.lang.all;
4 import java.util.Set;
5 import java.util.Collection;
6 import java.util.Iterator;
7
8 static import tango.util.container.HashSet;
9
10 class HashSet : Set {
11 alias tango.util.container.HashSet.HashSet!(Object) SetType;
12 private SetType set;
13
14 public this(){
15 set = new SetType();
16 }
17 public this(Collection c){
18 implMissing( __FILE__, __LINE__ );
19 }
20 public this(int initialCapacity){
21 implMissing( __FILE__, __LINE__ );
22 }
23 public this(int initialCapacity, float loadFactor){
24 implMissing( __FILE__, __LINE__ );
25 }
26 public bool add(Object o){
27 return set.add(o);
28 }
29 public bool add(String o){
30 return add(stringcast(o));
31 }
32 public bool addAll(Collection c){
33 implMissing( __FILE__, __LINE__ );
34 return false;
35 }
36 public void clear(){
37 set.clear();
38 }
39 public bool contains(Object o){
40 return set.contains(o);
41 }
42 public bool contains(String o){
43 return contains(stringcast(o));
44 }
45 public bool containsAll(Collection c){
46 implMissing( __FILE__, __LINE__ );
47 return false;
48 }
49 public override int opEquals(Object o){
50 implMissing( __FILE__, __LINE__ );
51 return 0;
52 }
53 public override hash_t toHash(){
54 implMissing( __FILE__, __LINE__ );
55 return 0;
56 }
57 public bool isEmpty(){
58 return set.isEmpty();
59 }
60 class LocalIterator : Iterator {
61 SetType.Iterator iter;
62 Object nextElem;
63 this( SetType.Iterator iter){
64 this.iter = iter;
65 }
66 public bool hasNext(){
67 return iter.next(nextElem);
68 }
69 public Object next(){
70 return nextElem;
71 }
72 public void remove(){
73 iter.remove();
74 }
75 }
76 public Iterator iterator(){
77 return new LocalIterator(set.iterator());
78 }
79 public bool remove(Object o){
80 return set.remove(o);
81 }
82 public bool remove(String key){
83 return remove(stringcast(key));
84 }
85 public bool removeAll(Collection c){
86 implMissing( __FILE__, __LINE__ );
87 return false;
88 }
89 public bool retainAll(Collection c){
90 implMissing( __FILE__, __LINE__ );
91 return false;
92 }
93 public int size(){
94 return set.size();
95 }
96 public Object[] toArray(){
97 Object[] res;
98 res.length = size();
99 int idx = 0;
100 foreach( o; set ){
101 res[idx] = o;
102 idx++;
103 }
104 return res;
105 }
106 public Object[] toArray(Object[] a){
107 implMissing( __FILE__, __LINE__ );
108 return null;
109 }
110 public override String toString(){
111 implMissing( __FILE__, __LINE__ );
112 return null;
113 }
114
115 // only for D
116 public int opApply (int delegate(ref Object value) dg){
117 return set.opApply(dg);
118 }
119
120 }
121