/// <summary>
 /// Have the specified consumer accept the value if a value is present,
 /// otherwise do nothing.
 /// </summary>
 /// <param name="consumer"> block to be executed if a value is present </param>
 /// <exception cref="NullPointerException"> if value is present and {@code consumer} is
 /// null </exception>
 public void IfPresent(DoubleConsumer consumer)
 {
     if (IsPresent)
     {
         consumer.Accept(Value);
     }
 }
            public bool TryAdvance(DoubleConsumer consumer)
            {
                if (consumer == null)
                {
                    throw new NullPointerException();
                }
                long i = Index, f = Fence;

                if (i < f)
                {
                    consumer.Accept(Rng.InternalNextDouble(Origin, Bound));
                    Index = i + 1;
                    return(true);
                }
                return(false);
            }
            public void ForEachRemaining(DoubleConsumer consumer)
            {
                if (consumer == null)
                {
                    throw new NullPointerException();
                }
                long i = Index, f = Fence;

                if (i < f)
                {
                    Index = f;
                    SplittableRandom r = Rng;
                    double           o = Origin, b = Bound;
                    do
                    {
                        consumer.Accept(r.InternalNextDouble(o, b));
                    } while (++i < f);
                }
            }
Beispiel #4
0
            public void ForEachRemaining(DoubleConsumer consumer)
            {
                if (consumer == null)
                {
                    throw new NullPointerException();
                }
                long i = Index, f = Fence;

                if (i < f)
                {
                    Index = f;
                    double            o = Origin, b = Bound;
                    ThreadLocalRandom rng = ThreadLocalRandom.Current();
                    do
                    {
                        consumer.Accept(rng.InternalNextDouble(o, b));
                    } while (++i < f);
                }
            }
 public DoubleConsumer andThen(DoubleConsumer arg0)
 {
     return Instance.CallMethod<DoubleConsumer>("andThen", "(Ljava/util/function/DoubleConsumer;)Ljava/util/function/DoubleConsumer;", arg0);
 }
Beispiel #6
0
 internal OfDouble(DoubleConsumer consumer, bool ordered) : base(ordered)
 {
     this.Consumer = consumer;
 }
Beispiel #7
0
 /// <summary>
 /// Constructs a {@code TerminalOp} that perform an action for every element
 /// of a {@code DoubleStream}.
 /// </summary>
 /// <param name="action"> the {@code DoubleConsumer} that receives all elements of
 ///        a stream </param>
 /// <param name="ordered"> whether an ordered traversal is requested </param>
 /// <returns> the {@code TerminalOp} instance </returns>
 public static TerminalOp <Double, Void> MakeDouble(DoubleConsumer action, bool ordered)
 {
     Objects.RequireNonNull(action);
     return(new ForEachOp.OfDouble(action, ordered));
 }