Esempio 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);
     }
 }
Esempio 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);
            }
Esempio 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);
                }
            }
Esempio 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);
                }
            }
Esempio n. 5
0
 public void Accept(long t)
 {
     Consumer.Accept(t);
 }