Exemplo n.º 1
0
 public virtual void ForEachRemaining(IntConsumer block)
 {
     for (; Cur < length(); Cur++)
     {
         block.Accept(charAt(Cur));
     }
 }
Exemplo n.º 2
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(IntConsumer consumer)
 {
     if (IsPresent)
     {
         consumer.Accept(Value);
     }
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
            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);
            }
Exemplo n.º 5
0
            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);
                }
            }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
        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++));
            }
        }
Exemplo n.º 8
0
            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);
            }
Exemplo n.º 9
0
            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);
                }
            }
Exemplo n.º 10
0
            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);
                }
            }
Exemplo n.º 11
0
 public void Accept(int t)
 {
     Consumer.Accept(t);
 }