Class Filter


  • public class Filter
    extends Object
    Utility class for filtering arrays and properties based on a boolean mask. The `Filter` class provides methods to filter integer and double arrays, as well as map properties containing arrays, based on a given boolean mask.
    • Constructor Detail

      • Filter

        public Filter()
    • Method Detail

      • filterArray

        public static int[] filterArray​(int[] peaks,
                                        boolean[] mask)
        Filters an integer array based on a boolean mask. This method creates a new array containing only the elements from `peaks` where the corresponding index in `mask` is `true`.
        Parameters:
        peaks - The input integer array to filter.
        mask - The boolean mask array. Must have the same length as `peaks`.
        Returns:
        A new integer array containing the filtered values.
        Throws:
        IllegalArgumentException - if `peaks` and `mask` have different lengths.
      • filterArray

        public static double[] filterArray​(double[] peaks,
                                           boolean[] mask)
        Filters a double array based on a boolean mask. This method creates a new array containing only the elements from `peaks` where the corresponding index in `mask` is `true`.
        Parameters:
        peaks - The input double array to filter.
        mask - The boolean mask array. Must have the same length as `peaks`.
        Returns:
        A new double array containing the filtered values.
        Throws:
        IllegalArgumentException - if `peaks` and `mask` have different lengths.
      • filterProperties

        public static void filterProperties​(Map<String,​Object> props,
                                            boolean[] mask)
        Filters properties in a map based on a boolean mask. This method updates the values of the map for keys that have arrays as values, applying the filtering operation only to arrays of type `int[]` or `double[]`. Other value types are ignored.
        Parameters:
        props - A map of properties where keys are strings and values are arrays. Only arrays of type `int[]` or `double[]` are processed.
        mask - The boolean mask array. Must have the same length as the arrays being filtered.
        Throws:
        IllegalArgumentException - if any array in the map has a different length than the `mask`.