Class IntegerSplitter

  • All Implemented Interfaces:
    Splitter<Integer>, Iterator<SplitRange<Integer>>

    public class IntegerSplitter
    extends Object
    implements Splitter<Integer>
    Integer splits iterator. Guarantees number of splits expected of a split range. Uses `(high-low)/numSplits + 1` as step to calculate splits. For a non-zero remainder `r`, extra value will be added to first `r` splits. Example: [1, 10] as input split range 1. expected splits = 2, remainder = 0 Splits = [1,5], [6,10] 2. expected splits = 3, remainder = 1 Splits = [1,4], [5,7], [8,10] // note that the remainder gets added in first split only. 3. expected splits = 4, remainder = 2 Splits = [1,3], [4,6], [7,8], [9,10] // note that the remainder gets distributed in first two splits.