//-------------------------------------------------------------------------
        /// <summary>
        /// Streams the set of dates included in the range.
        /// <para>
        /// This returns a stream consisting of each date in the range.
        /// The stream is ordered.
        ///
        /// </para>
        /// </summary>
        /// <param name="startInclusive">  the start date </param>
        /// <param name="endExclusive">  the end date </param>
        /// <returns> the stream of dates from the start to the end </returns>
        internal static Stream <LocalDate> stream(LocalDate startInclusive, LocalDate endExclusive)
        {
            IEnumerator <LocalDate> it = new IteratorAnonymousInnerClass(startInclusive, endExclusive);
            long count = endExclusive.toEpochDay() - startInclusive.toEpochDay() + 1;
            Spliterator <LocalDate> spliterator = Spliterators.spliterator(it, count, Spliterator.IMMUTABLE | Spliterator.NONNULL | Spliterator.DISTINCT | Spliterator.ORDERED | Spliterator.SORTED | Spliterator.SIZED | Spliterator.SUBSIZED);

            return(StreamSupport.stream(spliterator, false));
        }
예제 #2
0
        /// <summary>
        /// Create a stream from the given iterator with given characteristics.
        /// <para>
        /// <b>Note:</b> returned stream needs to be closed via <seealso cref="Stream.close()"/> if the given iterator implements
        /// <seealso cref="Resource"/>.
        ///
        /// </para>
        /// </summary>
        /// <param name="iterator"> the iterator to convert to stream </param>
        /// <param name="characteristics"> the logical OR of characteristics for the underlying <seealso cref="Spliterator"/> </param>
        /// @param <T> the type of elements in the given iterator </param>
        /// <returns> stream over the iterator elements </returns>
        /// <exception cref="NullPointerException"> when the given iterator is {@code null} </exception>
        public static Stream <T> Stream <T>(IEnumerator <T> iterator, int characteristics)
        {
            Objects.requireNonNull(iterator);
            Spliterator <T> spliterator = Spliterators.spliteratorUnknownSize(iterator, characteristics);
            Stream <T>      stream      = StreamSupport.stream(spliterator, false);

            if (iterator is Resource)
            {
                return(stream.onClose((( Resource )iterator).close));
            }
            return(stream);
        }
예제 #3
0
 public virtual ISpliterator <E> Spliterator()
 {
     if (iterable != null)
     {
         return(iterable.Spliterator());
     }
     else
     {
         if (stream != null)
         {
             return(stream.Spliterator());
         }
         else
         {
             return(Spliterators.SpliteratorUnknownSize(it, SpliteratorConstants.Ordered | SpliteratorConstants.Concurrent));
         }
     }
 }
예제 #4
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);
            }
예제 #5
0
 public virtual Stream <ScoreEntry> Stream()
 {
     return(StreamSupport.stream(Spliterators.spliteratorUnknownSize(this, Spliterator.ORDERED), false));
 }
예제 #6
0
        /// <summary>
        /// Returns a {@code Stream}, the elements of which are lines read from
        /// this {@code BufferedReader}.  The <seealso cref="Stream"/> is lazily populated,
        /// i.e., read only occurs during the
        /// <a href="../util/stream/package-summary.html#StreamOps">terminal
        /// stream operation</a>.
        ///
        /// <para> The reader must not be operated on during the execution of the
        /// terminal stream operation. Otherwise, the result of the terminal stream
        /// operation is undefined.
        ///
        /// </para>
        /// <para> After execution of the terminal stream operation there are no
        /// guarantees that the reader will be at a specific position from which to
        /// read the next character or line.
        ///
        /// </para>
        /// <para> If an <seealso cref="IOException"/> is thrown when accessing the underlying
        /// {@code BufferedReader}, it is wrapped in an {@link
        /// UncheckedIOException} which will be thrown from the {@code Stream}
        /// method that caused the read to take place. This method will return a
        /// Stream if invoked on a BufferedReader that is closed. Any operation on
        /// that stream that requires reading from the BufferedReader after it is
        /// closed, will cause an UncheckedIOException to be thrown.
        ///
        /// </para>
        /// </summary>
        /// <returns> a {@code Stream<String>} providing the lines of text
        ///         described by this {@code BufferedReader}
        ///
        /// @since 1.8 </returns>
        public virtual Stream <String> Lines()
        {
            IEnumerator <String> iter = new IteratorAnonymousInnerClassHelper(this);

            return(StreamSupport.Stream(Spliterators.SpliteratorUnknownSize(iter, java.util.Spliterator_Fields.ORDERED | java.util.Spliterator_Fields.NONNULL), false));
        }
예제 #7
0
 private static Stream <T> EnumerationAsStream <T>(IEnumerator <T> e)
 {
     return(StreamSupport.stream(Spliterators.spliteratorUnknownSize(new IteratorAnonymousInnerClass(e)
                                                                     , Spliterator.ORDERED), false));
 }
        /// <summary>
        /// Returns a stream that wraps this iterator.
        /// <para>
        /// The stream will process any remaining rows in the CSV file.
        /// As such, it is recommended that callers should use this method or the iterator methods and not both.
        ///
        /// </para>
        /// </summary>
        /// <returns> the stream wrapping this iterator </returns>
        public Stream <CsvRow> asStream()
        {
            Spliterator <CsvRow> spliterator = Spliterators.spliteratorUnknownSize(this, Spliterator.ORDERED | Spliterator.NONNULL);

            return(StreamSupport.stream(spliterator, false));
        }
예제 #9
0
 public Spliterator <Map_Entry <K, V> > Spliterator()
 {
     return(Spliterators.Spliterator(this, Spliterator_Fields.SIZED | Spliterator_Fields.ORDERED | Spliterator_Fields.DISTINCT));
 }
예제 #10
0
 public Spliterator <V> Spliterator()
 {
     return(Spliterators.Spliterator(this, Spliterator_Fields.SIZED | Spliterator_Fields.ORDERED));
 }
예제 #11
0
 public Spliterator <K> Spliterator()
 {
     return(Spliterators.Spliterator(this, Spliterator_Fields.SIZED | Spliterator_Fields.ORDERED | Spliterator_Fields.DISTINCT));
 }
예제 #12
0
 public override java.util.PrimitiveIterator_OfInt Iterator()
 {
     return(Spliterators.Iterator(Spliterator()));
 }
예제 #13
0
 public virtual IEnumerator <E> GetEnumerator()
 {
     return(Spliterators.Iterator(Spliterator()));
 }