Code refactor for AbsoluteMax improvements (#3029)

Fix #3028

Co-authored-by: Yang Libin <szuyanglb@outlook.com>
This commit is contained in:
Cristiano Jesus
2022-04-21 02:33:29 +01:00
committed by GitHub
parent 9f7613b467
commit c8b0a201da

View File

@ -21,11 +21,8 @@ public class AbsoluteMax {
Arrays.stream(numbers)
.skip(1)
.forEach(number -> {
if (Math.abs(number) > Math.abs(absMaxWrapper.value)) {
absMaxWrapper.value = number;
}
});
.filter(number -> Math.abs(number) > Math.abs(absMaxWrapper.value))
.forEach(number -> absMaxWrapper.value = number);
return absMaxWrapper.value;
}