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>
Spliteratorabstract base class that dispatches toSpliterators supplied through anSpliteratorofSpliteratorSuppliers.- 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 protectedDispatchSpliterator(long estimate, int characteristics)SeeSpliterators.AbstractSpliteratorconstructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static longbinomial(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 longbinomial(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 theSpliteratorSuppliers.booleantryAdvance(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.AbstractSpliteratorconstructor.- Parameters:
estimate- The estimated size ofthisSpliteratorif known, otherwiseLong.MAX_VALUE.characteristics- Properties of thisSpliterator's source or elements. IfSpliterator.SIZEDis reported thenthisSpliteratorwill additionally reportSpliterator.SUBSIZED.
-
-
Method Detail
-
spliterators
protected abstract Spliterator<Supplier<Spliterator<T>>> spliterators()
Method to provide theSpliteratorSuppliers. This method is called sometime after the first call totryAdvance(Consumer).- Returns:
- The
IteratorofSpliteratorSuppliers.
-
trySplit
public Spliterator<T> trySplit()
- Specified by:
trySplitin interfaceSpliterator<T>- Overrides:
trySplitin 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.
-
-