java.util.function.DoubleToIntFunction Java Examples
The following examples show how to use
java.util.function.DoubleToIntFunction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DoublePipeline.java From desugar_jdk_libs with GNU General Public License v2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #2
Source File: DoublePipeline.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #3
Source File: DoublePipeline.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #4
Source File: DoublePipeline.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #5
Source File: DoublePipeline.java From Java8CN with Apache License 2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #6
Source File: DoublePipeline.java From Bytecoder with Apache License 2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #7
Source File: DoublePipeline.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #8
Source File: DoublePipeline.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #9
Source File: DoublePipeline.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #10
Source File: DoublePipeline.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #11
Source File: DoublePipeline.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #12
Source File: DoublePipeline.java From JDKSourceCode1.8 with MIT License | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #13
Source File: DoublePipeline.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #14
Source File: DoublePipeline.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #15
Source File: DoublePipeline.java From j2objc with Apache License 2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override public Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #16
Source File: DoublePipeline.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #17
Source File: DoublePipeline.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #18
Source File: DoublePipeline.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #19
Source File: DoublePipeline.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public final IntStream mapToInt(DoubleToIntFunction mapper) { Objects.requireNonNull(mapper); return new IntPipeline.StatelessOp<Double>(this, StreamShape.DOUBLE_VALUE, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { return new Sink.ChainedDouble<Integer>(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); } }; } }; }
Example #20
Source File: Category.java From sis with Apache License 2.0 | 4 votes |
/** * Constructs a qualitative or quantitative category. This constructor is accessible for sub-classing. * For other usages, {@link SampleDimension.Builder} should be used instead. * * @param name the category name (mandatory). * @param samples the minimum and maximum sample values (mandatory). * @param toUnits the conversion from sample values to real values (possibly identity), or {@code null} * for constructing a qualitative category. Mandatory if {@code units} is non-null. * @param units the units of measurement, or {@code null} if not applicable. * This is the target units after conversion by {@code toUnits}. * @param toNaN mapping from sample values to ordinal values to be supplied to {@link MathFunctions#toNanFloat(int)}. * That mapping is used only if {@code toUnits} is {@code null} and {@code samples} are not NaN values. * That mapping is responsible to ensure that there is no ordinal value collision between different categories * in the same {@link SampleDimension}. * The input is a real number in the {@code samples} range and the output shall be a unique value between * {@value MathFunctions#MIN_NAN_ORDINAL} and {@value MathFunctions#MAX_NAN_ORDINAL} inclusive. * @throws IllegalSampleDimensionException if the {@code samples} range of values is empty * or the transfer function can not be used. */ protected Category(final CharSequence name, NumberRange<?> samples, final MathTransform1D toUnits, final Unit<?> units, final DoubleToIntFunction toNaN) { ArgumentChecks.ensureNonEmpty("name", name); ArgumentChecks.ensureNonNull("samples", samples); if (units != null) { ArgumentChecks.ensureNonNull("toUnits", toUnits); // The converse is not true: we allow 'units' to be null even if 'toUnits' is non-null. } this.name = Types.toInternationalString(name); final double minimum = samples.getMinDouble(true); final double maximum = samples.getMaxDouble(true); final boolean isNaN = Double.isNaN(minimum); /* * Following arguments check uses '!' in comparison in order to reject NaN values in quantitative category. * For qualitative category, NaN is accepted provided that it is the same NaN for both ends of the range. */ if (!(minimum <= maximum)) { if (toUnits != null || !isNaN || doubleToRawLongBits(minimum) != doubleToRawLongBits(maximum)) { throw new IllegalSampleDimensionException(Resources.format(Resources.Keys.IllegalCategoryRange_2, name, samples)); } } if (isNaN) { range = samples; converse = this; toConverse = identity(); } else try { /* * Creates the transform doing the inverse conversion (from real values to sample values). * This transform is assigned to a new Category object with its own minimum and maximum values. * Those minimum and maximum may be NaN if this category is a qualitative category. */ final MathTransform1D toSamples; if (toUnits != null) { toConverse = toUnits; if (toUnits.isIdentity()) { converse = this; if (!(samples instanceof MeasurementRange<?>)) { samples = new MeasurementRange<>(samples, units); // Avoid ClassCastException in getMeasurementRange(). } range = samples; return; } toSamples = toUnits.inverse(); } else { /* * For qualitative category, the transfer function maps to NaN while the inverse function maps back * to some value in the [minimum … maximum] range. We chose the value closest to positive zero. */ ArgumentChecks.ensureNonNull("toNaN", toNaN); final double value = (minimum > 0) ? minimum : (maximum <= 0) ? maximum : 0d; final float nan = MathFunctions.toNanFloat(toNaN.applyAsInt(value)); toConverse = (MathTransform1D) MathTransforms.linear(0, nan); toSamples = (MathTransform1D) MathTransforms.linear(0, value); } range = samples; converse = new ConvertedCategory(this, toSamples, toUnits != null, units); } catch (TransformException e) { throw new IllegalSampleDimensionException(Resources.format(Resources.Keys.IllegalTransferFunction_1, name), e); } }
Example #21
Source File: DoubleStreamEx.java From streamex with Apache License 2.0 | 4 votes |
@Override public IntStreamEx mapToInt(DoubleToIntFunction mapper) { return new IntStreamEx(stream().mapToInt(mapper), context); }
Example #22
Source File: DefaultMethodStreams.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public IntStream mapToInt(DoubleToIntFunction mapper) { return s.mapToInt(mapper); }
Example #23
Source File: DoubleStreamEx.java From streamex with Apache License 2.0 | 3 votes |
/** * Returns the minimum element of this stream according to the provided key * extractor function. * * <p> * This is a terminal operation. * * @param keyExtractor a non-interfering, stateless function * @return an {@code OptionalDouble} describing the first element of this * stream for which the lowest value was returned by key extractor, * or an empty {@code OptionalDouble} if the stream is empty * @since 0.1.2 */ public OptionalDouble minByInt(DoubleToIntFunction keyExtractor) { return collect(PrimitiveBox::new, (box, d) -> { int key = keyExtractor.applyAsInt(d); if (!box.b || box.i > key) { box.b = true; box.i = key; box.d = d; } }, PrimitiveBox.MIN_INT).asDouble(); }
Example #24
Source File: DoubleStreamEx.java From streamex with Apache License 2.0 | 3 votes |
/** * Returns the maximum element of this stream according to the provided key * extractor function. * * <p> * This is a terminal operation. * * @param keyExtractor a non-interfering, stateless function * @return an {@code OptionalDouble} describing the first element of this * stream for which the highest value was returned by key extractor, * or an empty {@code OptionalDouble} if the stream is empty * @since 0.1.2 */ public OptionalDouble maxByInt(DoubleToIntFunction keyExtractor) { return collect(PrimitiveBox::new, (box, d) -> { int key = keyExtractor.applyAsInt(d); if (!box.b || box.i < key) { box.b = true; box.i = key; box.d = d; } }, PrimitiveBox.MAX_INT).asDouble(); }
Example #25
Source File: DoubleStreamEx.java From streamex with Apache License 2.0 | 2 votes |
/** * Returns a stream consisting of the elements of this stream, sorted * according to the int values extracted by provided function. * * <p> * For ordered streams, the sort is stable. For unordered streams, no * stability guarantees are made. * * <p> * This is a <a href="package-summary.html#StreamOps">stateful intermediate * operation</a>. * * @param keyExtractor a * <a href="package-summary.html#NonInterference">non-interfering * </a>, <a href="package-summary.html#Statelessness">stateless</a> * function to be used to extract sorting keys * @return the new stream */ public DoubleStreamEx sortedByInt(DoubleToIntFunction keyExtractor) { return sorted(Comparator.comparingInt(keyExtractor::applyAsInt)); }
Example #26
Source File: DoubleStream.java From jdk8u-jdk with GNU General Public License v2.0 | 2 votes |
/** * Returns an {@code IntStream} consisting of the results of applying the * given function to the elements of this stream. * * <p>This is an <a href="package-summary.html#StreamOps">intermediate * operation</a>. * * @param mapper a <a href="package-summary.html#NonInterference">non-interfering</a>, * <a href="package-summary.html#Statelessness">stateless</a> * function to apply to each element * @return the new stream */ IntStream mapToInt(DoubleToIntFunction mapper);
Example #27
Source File: DoubleStream.java From jdk8u_jdk with GNU General Public License v2.0 | 2 votes |
/** * Returns an {@code IntStream} consisting of the results of applying the * given function to the elements of this stream. * * <p>This is an <a href="package-summary.html#StreamOps">intermediate * operation</a>. * * @param mapper a <a href="package-summary.html#NonInterference">non-interfering</a>, * <a href="package-summary.html#Statelessness">stateless</a> * function to apply to each element * @return the new stream */ IntStream mapToInt(DoubleToIntFunction mapper);
Example #28
Source File: DoubleStream.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 2 votes |
/** * Returns an {@code IntStream} consisting of the results of applying the * given function to the elements of this stream. * * <p>This is an <a href="package-summary.html#StreamOps">intermediate * operation</a>. * * @param mapper a <a href="package-summary.html#NonInterference">non-interfering</a>, * <a href="package-summary.html#Statelessness">stateless</a> * function to apply to each element * @return the new stream */ IntStream mapToInt(DoubleToIntFunction mapper);
Example #29
Source File: DoubleStream.java From j2objc with Apache License 2.0 | 2 votes |
/** * Returns an {@code IntStream} consisting of the results of applying the * given function to the elements of this stream. * * <p>This is an <a href="package-summary.html#StreamOps">intermediate * operation</a>. * * @param mapper a <a href="package-summary.html#NonInterference">non-interfering</a>, * <a href="package-summary.html#Statelessness">stateless</a> * function to apply to each element * @return the new stream */ IntStream mapToInt(DoubleToIntFunction mapper);
Example #30
Source File: DoubleStream.java From jdk8u-jdk with GNU General Public License v2.0 | 2 votes |
/** * Returns an {@code IntStream} consisting of the results of applying the * given function to the elements of this stream. * * <p>This is an <a href="package-summary.html#StreamOps">intermediate * operation</a>. * * @param mapper a <a href="package-summary.html#NonInterference">non-interfering</a>, * <a href="package-summary.html#Statelessness">stateless</a> * function to apply to each element * @return the new stream */ IntStream mapToInt(DoubleToIntFunction mapper);