|
@@ -51,7 +51,20 @@ public class MySet<T> extends MyArrayList implements Set {
|
51
|
51
|
|
52
|
52
|
@Override
|
53
|
53
|
public Iterator iterator() {
|
54
|
|
- return null;
|
|
54
|
+ Iterator<T> genericSetIterator = new Iterator<T>() {
|
|
55
|
+ int index = 0;
|
|
56
|
+
|
|
57
|
+ @Override
|
|
58
|
+ public boolean hasNext() {
|
|
59
|
+ return index < genericSet.length;
|
|
60
|
+ }
|
|
61
|
+
|
|
62
|
+ @Override
|
|
63
|
+ public T next() {
|
|
64
|
+ return genericSet[index++];
|
|
65
|
+ }
|
|
66
|
+ };
|
|
67
|
+ return genericSetIterator;
|
55
|
68
|
}
|
56
|
69
|
|
57
|
70
|
@Override
|
|
@@ -63,9 +76,7 @@ public class MySet<T> extends MyArrayList implements Set {
|
63
|
76
|
|
64
|
77
|
@Override
|
65
|
78
|
public boolean add(Object o) {
|
66
|
|
- super.add(o);
|
67
|
|
-
|
68
|
|
-
|
|
79
|
+ //super.add(o);
|
69
|
80
|
T[] newGenericSet = (T[]) Array.newInstance(this.genericSet.getClass().getComponentType(),
|
70
|
81
|
genericSet.length + 1);
|
71
|
82
|
|