Interface NaNTransformer

  • All Known Implementing Classes:
    NaNTransformers.ErrorNaNTransformer, NaNTransformers.ExcludeNaNTransformer, NaNTransformers.IncludeNaNTransformer
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    interface NaNTransformer
    Defines a transformer for NaN values in arrays.

    This interface is not intended for a public API. It provides a consistent method to handle partial sorting of double[] data in the Median and Quantile classes.

    The transformer allows pre-processing floating-point data before applying a sort algorithm. This is required to handle NaN.

    Note: The < relation does not provide a total order on all double values: -0.0 == 0.0 is true and a NaN value compares neither less than, greater than, nor equal to any value, even itself.

    The Double.compare(double, double) method imposes the ordering: -0.0 is treated as less than value 0.0 and Double.NaN is considered greater than any other value and all Double.NaN values are considered equal.

    This interface allows implementations to respect the behaviour of Double.compare(double, double), or implement different behaviour.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      double[] apply​(double[] data, int from, int to, int[] bounds)
      Pre-process the data for partitioning.
    • Method Detail

      • apply

        double[] apply​(double[] data,
                       int from,
                       int to,
                       int[] bounds)
        Pre-process the data for partitioning.

        This method will scan all the data and apply processing to NaN values.

        The method will return:

        • An array to partition; this may be a copy.
        • The bounds of the returned data as [start, end); this can be smaller than the input range if the transformer is configured to exclude NaN values. The start is inclusive and the end is exclusive.

        Implementations may assume the input [from, to) range is valid given the length of the data array.

        Parameters:
        data - Data.
        from - Inclusive start of the range.
        to - Exclusive end of the range.
        bounds - Set to [start, end).
        Returns:
        pre-processed data (may be a copy)