< prev index next >
src/java.base/share/classes/java/util/stream/LongPipeline.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 165,174 ****
--- 165,187 ----
@Override
final Node.Builder<Long> makeNodeBuilder(long exactSizeIfKnown, IntFunction<Long[]> generator) {
return Nodes.longBuilder(exactSizeIfKnown);
}
+ private final <U> Stream<U> mapToObj(LongFunction<? extends U> mapper, int opFlags) {
+ return new ReferencePipeline.StatelessOp<Long, U>(this, StreamShape.LONG_VALUE, opFlags) {
+ @Override
+ Sink<Long> opWrapSink(int flags, Sink<U> sink) {
+ return new Sink.ChainedLong<U>(sink) {
+ @Override
+ public void accept(long t) {
+ downstream.accept(mapper.apply(t));
+ }
+ };
+ }
+ };
+ }
// LongStream
@Override
public final PrimitiveIterator.OfLong iterator() {
*** 182,193 ****
// Stateless intermediate ops from LongStream
@Override
public final DoubleStream asDoubleStream() {
! return new DoublePipeline.StatelessOp<Long>(this, StreamShape.LONG_VALUE,
! StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
Sink<Long> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedLong<Double>(sink) {
@Override
public void accept(long t) {
--- 195,205 ----
// Stateless intermediate ops from LongStream
@Override
public final DoubleStream asDoubleStream() {
! return new DoublePipeline.StatelessOp<Long>(this, StreamShape.LONG_VALUE, StreamOpFlag.NOT_DISTINCT) {
@Override
Sink<Long> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedLong<Double>(sink) {
@Override
public void accept(long t) {
*** 198,208 ****
};
}
@Override
public final Stream<Long> boxed() {
! return mapToObj(Long::valueOf);
}
@Override
public final LongStream map(LongUnaryOperator mapper) {
Objects.requireNonNull(mapper);
--- 210,220 ----
};
}
@Override
public final Stream<Long> boxed() {
! return mapToObj(Long::valueOf, 0);
}
@Override
public final LongStream map(LongUnaryOperator mapper) {
Objects.requireNonNull(mapper);
*** 221,242 ****
}
@Override
public final <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
Objects.requireNonNull(mapper);
! return new ReferencePipeline.StatelessOp<Long, U>(this, StreamShape.LONG_VALUE,
! StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
! @Override
! Sink<Long> opWrapSink(int flags, Sink<U> sink) {
! return new Sink.ChainedLong<U>(sink) {
! @Override
! public void accept(long t) {
! downstream.accept(mapper.apply(t));
! }
! };
! }
! };
}
@Override
public final IntStream mapToInt(LongToIntFunction mapper) {
Objects.requireNonNull(mapper);
--- 233,243 ----
}
@Override
public final <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
Objects.requireNonNull(mapper);
! return mapToObj(mapper, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT);
}
@Override
public final IntStream mapToInt(LongToIntFunction mapper) {
Objects.requireNonNull(mapper);
< prev index next >