Class Split


  • public class Split
    extends Object
    For splitting data according to a percentage.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • Split

        public Split()
    • Method Detail

      • calcNumItems

        protected static int calcNumItems​(int total,
                                          double percentage)
        Calculates the number of items the percentage represents.
        Parameters:
        total - the total number of items
        percentage - the percentage to use (0-1)
        Returns:
        the number of items
      • split

        public static <T> com.github.fracpete.javautils.struct.Struct2<List<Binnable<T>>,​List<Binnable<T>>> split​(List<Binnable<T>> data,
                                                                                                                        double percentage)
        Splits the data into two, using the percentage for the first lot of data.
        Type Parameters:
        T - the payload type
        Parameters:
        data - the data to split
        percentage - the percentage (0-1)
        Returns:
        the split data
      • splitGroups

        public static <T> com.github.fracpete.javautils.struct.Struct2<List<BinnableGroup<T>>,​List<BinnableGroup<T>>> splitGroups​(List<BinnableGroup<T>> data,
                                                                                                                                        double percentage)
        Splits the grouped data into two, using the percentage for the first lot of data.
        Type Parameters:
        T - the payload type
        Parameters:
        data - the data to split
        percentage - the percentage (0-1)
        Returns:
        the split data