Package ball.util
Class DispatchSpliterator<T>
- java.lang.Object
-
- java.util.Spliterators.AbstractSpliterator<T>
-
- ball.util.DispatchSpliterator<T>
-
- All Implemented Interfaces:
Spliterator<T>
public abstract class DispatchSpliterator<T> extends Spliterators.AbstractSpliterator<T>
Spliterator
abstract base class that dispatches toSpliterator
s supplied through anSpliterator
ofSpliterator
Supplier
s.- Author:
- Allen D. Ball
-
-
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 inherited from interface java.util.Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DispatchSpliterator(long estimate, int characteristics)
SeeSpliterators.AbstractSpliterator
constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static long
binomial(long n, long k)
Method to count the number of combinations ofk
-size that may be chosen from a set ofn
-size (binomial coefficient).protected static long
binomial(long n, long k0, long kN)
Method to count the number of combinations of[k0,kN]
size that may be chosen from a set ofn
-size (binomial coefficient).protected abstract Spliterator<Supplier<Spliterator<T>>>
spliterators()
Method to provide theSpliterator
Supplier
s.boolean
tryAdvance(Consumer<? super T> consumer)
Spliterator<T>
trySplit()
-
Methods inherited from class java.util.Spliterators.AbstractSpliterator
characteristics, estimateSize
-
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
-
-
-
-
Constructor Detail
-
DispatchSpliterator
protected DispatchSpliterator(long estimate, int characteristics)
SeeSpliterators.AbstractSpliterator
constructor.- Parameters:
estimate
- The estimated size ofthis
Spliterator
if known, otherwiseLong.MAX_VALUE
.characteristics
- Properties of thisSpliterator
's source or elements. IfSpliterator.SIZED
is reported thenthis
Spliterator
will additionally reportSpliterator.SUBSIZED
.
-
-
Method Detail
-
spliterators
protected abstract Spliterator<Supplier<Spliterator<T>>> spliterators()
Method to provide theSpliterator
Supplier
s. This method is called sometime after the first call totryAdvance(Consumer)
.- Returns:
- The
Iterator
ofSpliterator
Supplier
s.
-
trySplit
public Spliterator<T> trySplit()
- Specified by:
trySplit
in interfaceSpliterator<T>
- Overrides:
trySplit
in classSpliterators.AbstractSpliterator<T>
-
tryAdvance
public boolean tryAdvance(Consumer<? super T> consumer)
-
binomial
protected static long binomial(long n, long k0, long kN)
Method to count the number of combinations of[k0,kN]
size that may be chosen from a set ofn
-size (binomial coefficient).- Parameters:
n
- The size of the set.k0
- The beginning of the interval (inclusive) of size of the subsets to be chosen.kN
- The end of the interval (inclusive) of size of the subsets to be chosen.- Returns:
- The total number of combinations.
-
binomial
protected static long binomial(long n, long k)
Method to count the number of combinations ofk
-size that may be chosen from a set ofn
-size (binomial coefficient).- Parameters:
n
- The size of the set.k
- The size of the subset to be chosen.- Returns:
- The total number of
k
-combinations.
-
-