/* * 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 list) { int sum = 0; for (Integer el : list) { sum = +el + x; } return sum; } void map_linear(Map map) { map.forEach((key, value) -> add(key, value)); } void list_linear(List 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 myList) { myList.forEach(el -> loop_linear(el, myList)); } }