Java Stream Operation mapElementsSizes(IntStream intStream)

Here you can find the source of mapElementsSizes(IntStream intStream)

Description

map Elements Sizes

License

Open Source License

Declaration

public static int mapElementsSizes(IntStream intStream) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.OptionalInt;

import java.util.stream.IntStream;

public class Main {
    public static int mapElementsSizes(IntStream intStream) {
        OptionalInt n = intStream.reduce((a, b) -> (a == -1) ? -1 : (b == 1) ? a : (a == b) ? a : (a == 1) ? b : -1
        //          reduce() return -1
        //                          no changes of a
        //                                         no changes of a
        //                                                        change to b
        //                                                             change to -1
        );//from  www  .ja v a2 s. c o m
        return n.isPresent() ? n.getAsInt() : 1;
    }
}

Related

  1. lazyPartition(final Stream stream, final int maxPartitionSize)
  2. lazyStream(PrimitiveIterator.OfLong iterator)
  3. longArray(Stream stream)
  4. longList(LongStream stream)
  5. makeStream(final Object[] array)
  6. maximum(final Stream stream)
  7. maxLong(Stream stream)
  8. maxStringLength(Stream stringStream)
  9. mkString(Stream items, String prefix, String delimiter, String suffix)