Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the Java 'super' constraint:
//ORIGINAL LINE: public boolean tryAdvance(java.util.function.Consumer<? base E> action)
            public bool tryAdvance <T1>(Consumer <T1> action)
            {
                Node <E> p;

                if (action == null)
                {
                    throw new NullPointerException();
                }
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final ConcurrentLinkedQueue<E> q = this.queue;
                ConcurrentLinkedQueue <E> q = this.Queue;

                if (!Exhausted && ((p = Current) != null || (p = q.First()) != null))
                {
                    E e;
                    do
                    {
                        e = p.Item;
                        if (p == (p = p.Next))
                        {
                            p = q.First();
                        }
                    } while (e == null && p != null);
                    if ((Current = p) == null)
                    {
                        Exhausted = true;
                    }
                    if (e != null)
                    {
                        action.Accept(e);
                        return(true);
                    }
                }
                return(false);
            }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the Java 'super' constraint:
//ORIGINAL LINE: public void forEachRemaining(java.util.function.Consumer<? base E> action)
            public void forEachRemaining <T1>(Consumer <T1> action)
            {
                Node <E> p;

                if (action == null)
                {
                    throw new NullPointerException();
                }
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final ConcurrentLinkedQueue<E> q = this.queue;
                ConcurrentLinkedQueue <E> q = this.Queue;

                if (!Exhausted && ((p = Current) != null || (p = q.First()) != null))
                {
                    Exhausted = true;
                    do
                    {
                        E e = p.Item;
                        if (p == (p = p.Next))
                        {
                            p = q.First();
                        }
                        if (e != null)
                        {
                            action.Accept(e);
                        }
                    } while (p != null);
                }
            }
Esempio n. 3
0
            public Spliterator <E> TrySplit()
            {
                Node <E> p;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final ConcurrentLinkedQueue<E> q = this.queue;
                ConcurrentLinkedQueue <E> q = this.Queue;
                int b = Batch;
                int n = (b <= 0) ? 1 : (b >= MAX_BATCH) ? MAX_BATCH : b + 1;

                if (!Exhausted && ((p = Current) != null || (p = q.First()) != null) && p.Next != null)
                {
                    Object[] a = new Object[n];
                    int      i = 0;
                    do
                    {
                        if ((a[i] = p.Item) != null)
                        {
                            ++i;
                        }
                        if (p == (p = p.Next))
                        {
                            p = q.First();
                        }
                    } while (p != null && i < n);
                    if ((Current = p) == null)
                    {
                        Exhausted = true;
                    }
                    if (i > 0)
                    {
                        Batch = i;
                        return(Spliterators.Spliterator(a, 0, i, java.util.Spliterator_Fields.ORDERED | java.util.Spliterator_Fields.NONNULL | java.util.Spliterator_Fields.CONCURRENT));
                    }
                }
                return(null);
            }