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.

37 lines
839 B

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* 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.List;
import java.util.Map;
class ForEachTest {
int add(Integer x, Integer y) {
return x + y;
}
int loop_linear(Integer x, List<Integer> list) {
int sum = 0;
for (Integer el : list) {
sum = +el + x;
}
return sum;
}
void map_linear(Map<Integer, Integer> map) {
map.forEach((key, value) -> add(key, value));
}
void list_linear(List<Integer> myList) {
myList.forEach(el -> add(el, 1));
}
// FN: We have limited lambda support and canot incur costs of the lambda calls yet.
void list_quadratic_FN(List<Integer> myList) {
myList.forEach(el -> loop_linear(el, myList));
}
}