jdk/src/java.base/share/classes/java/util/stream/package-info.java
changeset 47004 b7e72fc752c9
parent 44844 b2b4d98404ba
equal deleted inserted replaced
47003:7875699033bf 47004:b7e72fc752c9
     1 /*
     1 /*
     2  * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   413  * over a mutative accumulation such as the above.  Not only is a reduction
   413  * over a mutative accumulation such as the above.  Not only is a reduction
   414  * "more abstract" -- it operates on the stream as a whole rather than individual
   414  * "more abstract" -- it operates on the stream as a whole rather than individual
   415  * elements -- but a properly constructed reduce operation is inherently
   415  * elements -- but a properly constructed reduce operation is inherently
   416  * parallelizable, so long as the function(s) used to process the elements
   416  * parallelizable, so long as the function(s) used to process the elements
   417  * are <a href="package-summary.html#Associativity">associative</a> and
   417  * are <a href="package-summary.html#Associativity">associative</a> and
   418  * <a href="package-summary.html#NonInterfering">stateless</a>.
   418  * <a href="package-summary.html#Statelessness">stateless</a>.
   419  * For example, given a stream of numbers for which we want to find the sum, we
   419  * For example, given a stream of numbers for which we want to find the sum, we
   420  * can write:
   420  * can write:
   421  * <pre>{@code
   421  * <pre>{@code
   422  *    int sum = numbers.stream().reduce(0, (x,y) -> x+y);
   422  *    int sum = numbers.stream().reduce(0, (x,y) -> x+y);
   423  * }</pre>
   423  * }</pre>