Class TracedSpliterator<T>

  • Type Parameters:
    T - the type of the processed values
    All Implemented Interfaces:
    Spliterator<T>

    class TracedSpliterator<T>
    extends Object
    implements Spliterator<T>
    Spliterator with tracing. Wraps a the real spliterator.
    Author:
    Herbert Praehofer
    • Field Detail

      • realSpliterator

        final Spliterator<T> realSpliterator
        Reference to the real spliterator.
      • name

        final String name
        A name for the spliterator used for trace output.
      • splits

        int splits
        Count for splits
    • Constructor Detail

      • TracedSpliterator

        public TracedSpliterator​(Spliterator<T> realSpliterator,
                                 String name)
        Constructor setting the real spliterator and a name.
        Parameters:
        realSpliterator - the real spliterator
        name - the name
    • Method Detail

      • tryAdvance

        public boolean tryAdvance​(Consumer<? super T> action)
        Applies the consumer action on the next element. Calls the real spliterator and additionally writes some trace information.
        Specified by:
        tryAdvance in interface Spliterator<T>
        Parameters:
        action - the consumer function
        Returns:
        true if next element exists
      • trySplit

        public Spliterator<T> trySplit()
        Tries a split and returns a spliterator. Calls the real spliterator and additionally writes some trace information.
        Specified by:
        trySplit in interface Spliterator<T>
        Returns:
        the split spliterator
      • estimateSize

        public long estimateSize()
        Asks the real spliterator for the estimated size.
        Specified by:
        estimateSize in interface Spliterator<T>
        Returns:
        the estimated size
      • characteristics

        public int characteristics()
        Calls the real spliterator for returning the characteristics.
        Specified by:
        characteristics in interface Spliterator<T>
        Returns:
        the characteristics