|
@@ -16,13 +16,17 @@ public class MyArrayList<T> {
|
16
|
16
|
|
17
|
17
|
public void add(T data) {
|
18
|
18
|
|
19
|
|
- Object[] tempArray = new Object[getSize() + 1];
|
20
|
|
- tempArray[size] = data;
|
21
|
|
- this.myArrayList = tempArray;
|
22
|
|
- setSizeBy1();
|
|
19
|
+ Object[] tempArray = new Object[getSize() + 1];
|
|
20
|
+ tempArray[size] = data;
|
|
21
|
+ this.myArrayList = tempArray;
|
|
22
|
+ setSizeBy1();
|
23
|
23
|
|
24
|
24
|
}
|
25
|
25
|
|
|
26
|
+ public void add(T data, int index) {
|
|
27
|
+
|
|
28
|
+ }
|
|
29
|
+
|
26
|
30
|
public int getSize() {
|
27
|
31
|
return this.size;
|
28
|
32
|
}
|
|
@@ -79,4 +83,14 @@ public class MyArrayList<T> {
|
79
|
83
|
public boolean isEmpty() {
|
80
|
84
|
return (getSize() == 0);
|
81
|
85
|
}
|
|
86
|
+
|
|
87
|
+ public boolean contains(T data) {
|
|
88
|
+
|
|
89
|
+ for (int i = 0; i < getSize(); i++) {
|
|
90
|
+ if (myArrayList[i].equals(data))
|
|
91
|
+ return true;
|
|
92
|
+ }
|
|
93
|
+
|
|
94
|
+ return false;
|
|
95
|
+ }
|
82
|
96
|
}
|