Class SplitPointHandler<T extends SplitPointUnit,​U extends SplitPointDataSource<T,​U>>

  • Type Parameters:
    T - the type of split point units
    U - the type of data source

    public class SplitPointHandler<T extends SplitPointUnit,​U extends SplitPointDataSource<T,​U>>
    extends Object
    Breaks units into results. All allowed break points are supplied with the input.
    • Constructor Detail

      • SplitPointHandler

        public SplitPointHandler()
    • Method Detail

      • split

        @SafeVarargs
        public static <T extends SplitPointUnitSplitPoint<T,​SplitPointDataList<T>> split​(float breakPoint,
                                                                                                 T... units)
        Splits the data at, or before, the supplied breakPoint according to the rules in the data. If force is used, rules may be broken to achieve a result.
        Type Parameters:
        T - the type of split point units
        Parameters:
        breakPoint - the split point
        units - the data
        Returns:
        returns a split point result
      • split

        public static <T extends SplitPointUnitSplitPoint<T,​SplitPointDataList<T>> split​(float breakPoint,
                                                                                                 List<T> units,
                                                                                                 SplitOption... options)
        Splits the data at, or before, the supplied breakPoint according to the rules in the data. If force is used, rules may be broken to achieve a result.
        Type Parameters:
        T - the type of split point units
        Parameters:
        breakPoint - the split point
        units - the data
        options - the split options
        Returns:
        returns a split point result
      • split

        public static <T extends SplitPointUnitSplitPoint<T,​SplitPointDataList<T>> split​(float breakPoint,
                                                                                                 List<T> units,
                                                                                                 SplitPointCost<T> cost,
                                                                                                 SplitOption... options)
        Splits the data at, or before, the supplied breakPoint according to the rules in the data. If force is used, rules may be broken to achieve a result.
        Type Parameters:
        T - the type of split point units
        Parameters:
        breakPoint - the split point
        units - the data
        cost - the cost function used when determining the optimal forced split point. In other words, the cost function is only used if there are no breakable units available.
        options - the split options
        Returns:
        returns a split point result
      • split

        public SplitPoint<T,​U> split​(float breakPoint,
                                           U data,
                                           SplitOption... options)
        Splits the data at, or before, the supplied breakPoint according to the rules in the data. If force is used, rules may be broken to achieve a result.
        Parameters:
        breakPoint - the split point
        data - the data to split
        options - the split options
        Returns:
        returns a split point result
      • split

        public SplitPoint<T,​U> split​(float breakPoint,
                                           U data,
                                           SplitPointCost<T> cost,
                                           SplitOption... options)
        Splits the data at, or before, the supplied breakPoint according to the rules in the data. If force is used, rules may be broken to achieve a result.
        Parameters:
        breakPoint - the split point
        data - the data to split
        cost - the cost function used when determining the optimal forced split point. In other words, the cost function is only used if there are no breakable units available.
        options - the split options
        Returns:
        returns a split point result
        Throws:
        IllegalArgumentException - if cost is null
      • find

        public SplitPointSpecification find​(float breakPoint,
                                            U data,
                                            SplitOption... options)
        Finds a split point at, or before, the supplied breakPoint according to the rules in the data. If force is used, rules may be broken to achieve a result.
        Parameters:
        breakPoint - the split point
        data - the data to split
        options - the split options
        Returns:
        returns a split point specification
      • find

        public SplitPointSpecification find​(float breakPoint,
                                            U data,
                                            SplitPointCost<T> cost,
                                            SplitOption... options)
        Finds a split point at, or before, the supplied breakPoint according to the rules in the data. If force is used, rules may be broken to achieve a result.
        Parameters:
        breakPoint - the split point
        data - the data to split
        cost - the cost function used when determining the optimal forced split point. In other words, the cost function is only used if there are no breakable units available.
        options - the split options
        Returns:
        returns a split point specification
      • trimLeading

        public static <T extends SplitPointUnitSplitList<T> trimLeading​(List<T> in)
        Trims leading skippable units in the supplied list. The result is backed by the original list.
        Type Parameters:
        T - the type of split list
        Parameters:
        in - the list to trim
        Returns:
        the list split in two parts, one with the leading skippable units, one with the remainder
      • trimLeading

        public static <T extends SplitPointUnit,​U extends SplitPointDataSource<T,​U>> SplitPoint<T,​U> trimLeading​(U in)
        Trims leading skippable units in the supplied data source. The result is backed by the original data source.
        Type Parameters:
        T - the type of split list
        U - the type of data source
        Parameters:
        in - the list to trim
        Returns:
        a split point, the leading skippable units are placed in SplitPoint.getDiscarded(), the remainder are placed in SplitPoint.getTail()
      • skipLeading

        public static <T extends SplitPointUnit,​U extends SplitPointDataSource<T,​U>> SplitPoint<T,​U> skipLeading​(U in,
                                                                                                                                   int index)
        Skips leading units in the supplied list. The result is backed by the original data source. No data is beyond index is produced using this method.
        Type Parameters:
        T - the type of object
        U - the type of data source
        Parameters:
        in - the list to trim
        index - the index of the split point
        Returns:
        a split point, the leading units are placed in SplitPoint.getDiscarded(), the remainder are placed in SplitPoint.getTail()
      • findLeading

        public static <T extends SplitPointUnit,​U extends SplitPointDataSource<T,​U>> int findLeading​(U in)
        Finds leading skippable units in the supplied data source.
        Type Parameters:
        T - the type of object
        U - the type of data source
        Parameters:
        in - the data source to search
        Returns:
        returns the index of the first non-skippable unit