Class StreamGatherersExamples

java.lang.Object
net.jrodolfo.java_evolution.java24.StreamGatherersExamples

public class StreamGatherersExamples extends Object
Demonstrates Stream Gatherers, finalized in Java 24.

Before gatherers, custom intermediate stream operations were difficult to express. Developers often had to leave the stream pipeline or force the problem into a terminal collector. Gatherers let streams model operations such as fixed windows and running scans as part of the pipeline.

  • Constructor Details

    • StreamGatherersExamples

      public StreamGatherersExamples()
  • Method Details

    • fixedWindows

      public List<List<Integer>> fixedWindows(List<Integer> values, int size)
      Groups values into fixed-size windows.
      Parameters:
      values - values to window
      size - window size
      Returns:
      fixed-size windows, with a smaller final window when needed
    • runningSum

      public List<Integer> runningSum(List<Integer> values)
      Produces a running sum.
      Parameters:
      values - values to scan
      Returns:
      running sum after each value