@@ -172,7 +172,7 @@ public <R> ArrayListCustom<R> map(Function<T, R> o) {
172
172
173
173
public T findFirst (Predicate <T > o ) {
174
174
Objects .requireNonNull (o );
175
- for (Object item : this .arr ) {
175
+ for (Object item : this .toArray () ) {
176
176
T t = (T ) item ;
177
177
if (o .test (t )) return t ;
178
178
}
@@ -181,7 +181,7 @@ public T findFirst(Predicate<T> o) {
181
181
182
182
public boolean allMatch (Predicate <T > o ) {
183
183
Objects .requireNonNull (o );
184
- for (Object item : this .arr ) {
184
+ for (Object item : this .toArray () ) {
185
185
T t = (T ) item ;
186
186
if (!o .test (t )) return false ;
187
187
}
@@ -190,7 +190,7 @@ public boolean allMatch(Predicate<T> o) {
190
190
191
191
public boolean anyMatch (Predicate <T > o ) {
192
192
Objects .requireNonNull (o );
193
- for (Object item : this .arr ) {
193
+ for (Object item : this .toArray () ) {
194
194
T t = (T ) item ;
195
195
if (o .test (t )) return true ;
196
196
}
@@ -200,7 +200,7 @@ public boolean anyMatch(Predicate<T> o) {
200
200
public int findFirstIndex (Predicate <T > o ) {
201
201
Objects .requireNonNull (o );
202
202
int i = 0 ;
203
- for (Object item : this .arr ) {
203
+ for (Object item : this .toArray () ) {
204
204
T t = (T ) item ;
205
205
if (o .test (t )) return i ;
206
206
i ++;
@@ -216,7 +216,7 @@ public T max(Comparator<? super T> comparator) {
216
216
Objects .requireNonNull (comparator );
217
217
if (arr .length == 0 ) return null ;
218
218
T maxValue = (T ) arr [0 ];
219
- for (Object val : arr ) {
219
+ for (Object val : toArray () ) {
220
220
T item = (T ) val ;
221
221
int compareValue = comparator .compare (item , maxValue );
222
222
if (compareValue > 0 ) maxValue = item ;
@@ -228,7 +228,7 @@ public T min(Comparator<? super T> comparator) {
228
228
Objects .requireNonNull (comparator );
229
229
if (arr .length == 0 ) return null ;
230
230
T minValue = (T ) arr [0 ];
231
- for (Object val : arr ) {
231
+ for (Object val : toArray () ) {
232
232
T item = (T ) val ;
233
233
int compareValue = comparator .compare (item , minValue );
234
234
if (compareValue < 0 ) minValue = item ;
@@ -238,7 +238,7 @@ public T min(Comparator<? super T> comparator) {
238
238
239
239
public boolean noneMatch (Predicate <T > p ) {
240
240
Objects .requireNonNull (p );
241
- for (Object val : arr ) {
241
+ for (Object val : toArray () ) {
242
242
T item = (T ) val ;
243
243
if (p .test (item )) return false ;
244
244
}
0 commit comments