Package at.jku.ssw.fp.sect08_2
Class TracedSpliterator<T>
- java.lang.Object
-
- at.jku.ssw.fp.sect08_2.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface java.util.Spliterator
Spliterator.OfDouble, Spliterator.OfInt, Spliterator.OfLong, Spliterator.OfPrimitive<T extends Object,T_CONS extends Object,T_SPLITR extends Spliterator.OfPrimitive<T,T_CONS,T_SPLITR>>
-
-
Field Summary
Fields Modifier and Type Field Description (package private) String
name
A name for the spliterator used for trace output.(package private) Spliterator<T>
realSpliterator
Reference to the real spliterator.(package private) int
splits
Count for splits-
Fields inherited from interface java.util.Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED
-
-
Constructor Summary
Constructors Constructor Description TracedSpliterator(Spliterator<T> realSpliterator, String name)
Constructor setting the real spliterator and a name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
characteristics()
Calls the real spliterator for returning the characteristics.long
estimateSize()
Asks the real spliterator for the estimated size.boolean
tryAdvance(Consumer<? super T> action)
Applies the consumer action on the next element.Spliterator<T>
trySplit()
Tries a split and returns a spliterator.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Spliterator
forEachRemaining, getComparator, getExactSizeIfKnown, hasCharacteristics
-
-
-
-
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 spliteratorname
- 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 interfaceSpliterator<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 interfaceSpliterator<T>
- Returns:
- the split spliterator
-
estimateSize
public long estimateSize()
Asks the real spliterator for the estimated size.- Specified by:
estimateSize
in interfaceSpliterator<T>
- Returns:
- the estimated size
-
characteristics
public int characteristics()
Calls the real spliterator for returning the characteristics.- Specified by:
characteristics
in interfaceSpliterator<T>
- Returns:
- the characteristics
-
-