Exemplo n.º 1
0
 /// <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(LongConsumer consumer)
 {
     if (IsPresent)
     {
         consumer.Accept(Value);
     }
 }
Exemplo n.º 2
0
            public bool TryAdvance(LongConsumer consumer)
            {
                if (consumer == null)
                {
                    throw new NullPointerException();
                }
                long i = Index, f = Fence;

                if (i < f)
                {
                    consumer.Accept(Rng.InternalNextLong(Origin, Bound));
                    Index = i + 1;
                    return(true);
                }
                return(false);
            }
Exemplo n.º 3
0
            public void ForEachRemaining(LongConsumer consumer)
            {
                if (consumer == null)
                {
                    throw new NullPointerException();
                }
                long i = Index, f = Fence;

                if (i < f)
                {
                    Index = f;
                    SplittableRandom r = Rng;
                    long             o = Origin, b = Bound;
                    do
                    {
                        consumer.Accept(r.InternalNextLong(o, b));
                    } while (++i < f);
                }
            }
Exemplo n.º 4
0
            public void ForEachRemaining(LongConsumer consumer)
            {
                if (consumer == null)
                {
                    throw new NullPointerException();
                }
                long i = Index, f = Fence;

                if (i < f)
                {
                    Index = f;
                    long o = Origin, b = Bound;
                    ThreadLocalRandom rng = ThreadLocalRandom.Current();
                    do
                    {
                        consumer.Accept(rng.InternalNextLong(o, b));
                    } while (++i < f);
                }
            }
Exemplo n.º 5
0
 /// <summary>
 /// Constructs a {@code TerminalOp} that perform an action for every element
 /// of a {@code LongStream}.
 /// </summary>
 /// <param name="action"> the {@code LongConsumer} 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 <Long, Void> MakeLong(LongConsumer action, bool ordered)
 {
     Objects.RequireNonNull(action);
     return(new ForEachOp.OfLong(action, ordered));
 }
Exemplo n.º 6
0
 internal OfLong(LongConsumer consumer, bool ordered) : base(ordered)
 {
     this.Consumer = consumer;
 }
 public LongConsumer andThen(LongConsumer arg0)
 {
     return Instance.CallMethod<LongConsumer>("andThen", "(Ljava/util/function/LongConsumer;)Ljava/util/function/LongConsumer;", arg0);
 }