equal
deleted
inserted
replaced
466 * re-cast the simple sum-of-weights example using the more general form as |
466 * re-cast the simple sum-of-weights example using the more general form as |
467 * follows: |
467 * follows: |
468 * <pre>{@code |
468 * <pre>{@code |
469 * int sumOfWeights = widgets.stream() |
469 * int sumOfWeights = widgets.stream() |
470 * .reduce(0, |
470 * .reduce(0, |
471 * (sum, b) -> sum + b.getWeight()) |
471 * (sum, b) -> sum + b.getWeight(), |
472 * Integer::sum); |
472 * Integer::sum); |
473 * }</pre> |
473 * }</pre> |
474 * though the explicit map-reduce form is more readable and therefore should |
474 * though the explicit map-reduce form is more readable and therefore should |
475 * usually be preferred. The generalized form is provided for cases where |
475 * usually be preferred. The generalized form is provided for cases where |
476 * significant work can be optimized away by combining mapping and reducing |
476 * significant work can be optimized away by combining mapping and reducing |