You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
761 B
35 lines
761 B
6 years ago
|
/*
|
||
6 years ago
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
6 years ago
|
*
|
||
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
|
*/
|
||
|
import java.util.*;
|
||
|
|
||
|
class Iterators {
|
||
6 years ago
|
void hasNextOk(List<Integer> xs) {
|
||
|
Iterator<Integer> i = xs.iterator();
|
||
|
if (i.hasNext()) i.next();
|
||
|
}
|
||
|
|
||
|
void hasNextBad(List<Integer> xs) {
|
||
|
Iterator<Integer> i = xs.iterator();
|
||
|
i.next();
|
||
|
}
|
||
|
|
||
|
void hasNextInterproceduralBad(List<Integer> xs) {
|
||
|
getSingleElementOk(xs.iterator());
|
||
|
}
|
||
|
|
||
|
void hasNextInterproceduralOk(List<Integer> xs) {
|
||
|
Iterator<Integer> i = xs.iterator();
|
||
|
if (i.hasNext()) {
|
||
|
getSingleElementOk(i);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void getSingleElementOk(Iterator<Integer> i) {
|
||
6 years ago
|
i.next();
|
||
|
}
|
||
|
}
|