Class Wrapping


  • public class Wrapping
    extends Object
    For wrapping data.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • TMP_INDEX

        public static final String TMP_INDEX
        the temporary index stored in the binnable meta-data.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Wrapping

        public Wrapping()
    • Method Detail

      • wrap

        public static List<Binnable<Integer>> wrap​(double[] values)
                                            throws Exception
        Wraps the double array in binnable objects, using the index as payload.
        Parameters:
        values - the values to wrap
        Returns:
        the wrapped indices/values
        Throws:
        Exception - if NaN value is encountered
      • wrap

        public static List<Binnable<Integer>> wrap​(float[] values)
                                            throws Exception
        Wraps the float array in binnable objects, using the index as payload.
        Parameters:
        values - the values to wrap
        Returns:
        the wrapped indices/values
        Throws:
        Exception - if NaN value is encountered
      • wrap

        public static List<Binnable<Integer>> wrap​(Number[] values)
                                            throws Exception
        Wraps the double array in binnable objects, using the index as payload.
        Parameters:
        values - the values to wrap
        Returns:
        the wrapped indices/values
        Throws:
        Exception - if NaN value is encountered
      • wrap

        public static List<Binnable<Integer>> wrap​(Collection<Number> values)
                                            throws Exception
        Wraps the double array in binnable objects, using the index as payload.
        Parameters:
        values - the values to wrap
        Returns:
        the wrapped indices/values
        Throws:
        Exception - if NaN value is encountered
      • wrap

        public static <T> List<Binnable<T>> wrap​(T[] values,
                                                 Wrapping.BinValueExtractor<T> extractor)
                                          throws Exception
        Wraps the array in binnable objects, using the extractor to determine the value for the binnable object.
        Parameters:
        values - the values to wrap
        extractor - for extracting the bin value from the objects
        Returns:
        the wrapped values
        Throws:
        Exception
      • wrap

        public static <T> List<Binnable<T>> wrap​(Collection<T> values,
                                                 Wrapping.BinValueExtractor<T> extractor)
                                          throws Exception
        Wraps the collection in binnable objects, using the extractor to determine the value for the binnable object.
        Parameters:
        values - the values to wrap
        extractor - for extracting the value from the objects
        Returns:
        the wrapped values
        Throws:
        Exception
      • wrapGroups

        public static <T> List<Binnable<BinnableGroup<T>>> wrapGroups​(Collection<BinnableGroup<T>> values,
                                                                      Wrapping.BinValueExtractor<T> extractor)
                                                               throws Exception
        Wraps the collection of binnable group objects in binnable objects, using the extractor to determine the value for the binnable object (uses first item of group).
        Parameters:
        values - the values to wrap
        extractor - for extracting the value from the objects
        Returns:
        the wrapped values
        Throws:
        Exception
      • unwrap

        public static <T> List<T> unwrap​(List<Binnable<T>> data)
        Unwraps the payloads from the binnable list.
        Type Parameters:
        T - the type of payload
        Parameters:
        data - the data to unwrap
        Returns:
        the payload list
      • addTmpIndex

        public static <T> List<Binnable<T>> addTmpIndex​(List<Binnable<T>> data)
        Adds the list index under a temporary key TMP_INDEX.
        Type Parameters:
        T - the payload type
        Parameters:
        data - the data to enumerate
        Returns:
        the updated (input)
      • getTmpIndices

        public static <T> gnu.trove.list.TIntList getTmpIndices​(List<Binnable<T>> data)
        Collects indices stored under TMP_INDEX.
        Parameters:
        data - the data to retrieve the indices from
        Returns:
        the indices
      • removeTmpIndex

        public static <T> List<Binnable<T>> removeTmpIndex​(List<Binnable<T>> data)
        Removes the list index under a temporary key TMP_INDEX.
        Type Parameters:
        T - the payload type
        Parameters:
        data - the data to enumerate
        Returns:
        the updated (input)