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