/// <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(IntConsumer consumer) { if (IsPresent) { consumer.Accept(Value); } }
public virtual void ForEachRemaining(IntConsumer block) { for (; Cur < length(); Cur++) { block.Accept(charAt(Cur)); } }
public virtual bool TryAdvance(IntConsumer action) { if (action == null) { throw new NullPointerException(); } if (Index >= 0 && Index < Limit) { action.Accept(Buffer.GetUnchecked(Index++)); return(true); } return(false); }
public override void ForEachRemaining(IntConsumer action) { if (action == null) { throw new NullPointerException(); } CharBuffer cb = Buffer; int i = Index; int hi = Limit; Index = hi; while (i < hi) { action.Accept(cb.GetUnchecked(i++)); } }
public bool TryAdvance(IntConsumer consumer) { if (consumer == null) { throw new NullPointerException(); } long i = Index, f = Fence; if (i < f) { consumer.Accept(Rng.InternalNextInt(Origin, Bound)); Index = i + 1; return(true); } return(false); }
public void ForEachRemaining(IntConsumer consumer) { if (consumer == null) { throw new NullPointerException(); } long i = Index, f = Fence; if (i < f) { Index = f; SplittableRandom r = Rng; int o = Origin, b = Bound; do { consumer.Accept(r.InternalNextInt(o, b)); } while (++i < f); } }
public void ForEachRemaining(IntConsumer consumer) { if (consumer == null) { throw new NullPointerException(); } long i = Index, f = Fence; if (i < f) { Index = f; int o = Origin, b = Bound; ThreadLocalRandom rng = ThreadLocalRandom.Current(); do { consumer.Accept(rng.InternalNextInt(o, b)); } while (++i < f); } }
public bool TryAdvance(IntConsumer consumer) { Objects.RequireNonNull(consumer); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int i = from; int i = From; if (i < UpTo) { From++; consumer.Accept(i); return(true); } else if (Last > 0) { Last = 0; consumer.Accept(i); return(true); } return(false); }
public override void ForEachRemaining(IntConsumer consumer) { Objects.RequireNonNull(consumer); int i = From; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int hUpTo = upTo; int hUpTo = UpTo; int hLast = Last; From = UpTo; Last = 0; while (i < hUpTo) { consumer.Accept(i++); } if (hLast > 0) { // Last element of closed range consumer.Accept(i); } }
public void HeterogeneityDispatchTest_有2個consumer_主動通知() { var queue = GetQueue(); var dispatch = new HeterogeneityDispatch(); dispatch.Binding(queue); var consumer1 = new IntConsumer(); dispatch.Register(consumer1); var consumer2 = new StringConsumer(); dispatch.Register(consumer2); Task.Factory.StartNew(() => dispatch.Notice()); Thread.Sleep(200); (new[] { 24, 36 }).ToExpectedObject().ShouldEqual(consumer1.Queue.ToArray()); (new[] { "Flora MQ", "Message Queue" }).ToExpectedObject().ShouldEqual(consumer2.Queue.ToArray()); }
public virtual void ForEachRemaining(IntConsumer block) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int length = length(); int length = length(); int i = Cur; try { while (i < length) { char c1 = charAt(i++); if (!char.IsHighSurrogate(c1) || i >= length) { block.Accept(c1); } else { char c2 = charAt(i); if (char.IsLowSurrogate(c2)) { i++; block.Accept(Character.ToCodePoint(c1, c2)); } else { block.Accept(c1); } } } } finally { Cur = i; } }
public void HeterogeneityDispatchTest_兩個consumer依順序取值() { var queue = GetQueue(); var dispatch = new HeterogeneityDispatch(); dispatch.Binding(queue); var consumer1 = new IntConsumer(); dispatch.Register(consumer1); var consumer2 = new StringConsumer(); dispatch.Register(consumer2); consumer1.DoWork(); consumer2.DoWork(); consumer1.DoWork(); consumer2.DoWork(); (new[] { 24, 36 }).ToExpectedObject().ShouldEqual(consumer1.Queue.ToArray()); (new[] { "Flora MQ", "Message Queue" }).ToExpectedObject().ShouldEqual(consumer2.Queue.ToArray()); }
public void HeterogeneityDispatchTest_當只有一個consume取值時() { var queue = GetQueue(); var dispatch = new HeterogeneityDispatch(); dispatch.Binding(queue); var consumer1 = new IntConsumer(); dispatch.Register(consumer1); var consumer2 = new StringConsumer(); dispatch.Register(consumer2); consumer1.DoWork(); consumer1.DoWork(); consumer1.DoWork(); consumer1.DoWork(); (new[] { 24 }).ToExpectedObject().ShouldEqual(consumer1.Queue.ToArray()); (new string[] { }).ToExpectedObject().ShouldEqual(consumer2.Queue.ToArray()); }
public IntConsumer andThen(IntConsumer arg0) { return Instance.CallMethod<IntConsumer>("andThen", "(Ljava/util/function/IntConsumer;)Ljava/util/function/IntConsumer;", arg0); }
/// <summary> /// Constructs a {@code TerminalOp} that perform an action for every element /// of an {@code IntStream}. /// </summary> /// <param name="action"> the {@code IntConsumer} 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 <Integer, Void> MakeInt(IntConsumer action, bool ordered) { Objects.RequireNonNull(action); return(new ForEachOp.OfInt(action, ordered)); }
internal OfInt(IntConsumer consumer, bool ordered) : base(ordered) { this.Consumer = consumer; }