Class Bins<T>

  • Type Parameters:
    T - object type

    public class Bins<T>
    extends Object
    This class divides the items based on their keys into a number of bins. Information can be extracted from each bin.
    • Constructor Detail

      • Bins

        public Bins​(int n)
        Constructs an empty bin of valued items.
        Parameters:
        n - the number of bins
      • Bins

        public Bins​(int n,
                    Map<Double,​T> items)
        Constructs a bin with valued items.
        Parameters:
        n - the number of bins
        items - a collection of valued items
    • Method Detail

      • add

        public void add​(double key,
                        T item)
        Add a valued item to the bin.
        Parameters:
        key - the value
        item - the item
      • getBins

        public List<TreeMap<Double,​T>> getBins()
        Divides the items into n bins. If the total cannot be evenly divided, the last bin may be not fully filled. If the n-th bin is empty, only n - 1 bins are returned.
        Returns:
        the bins
      • getBinKeyValues

        public double[] getBinKeyValues​(RealScalarFunction f)
        Applies a function to the key of each bin.
        Parameters:
        f - a function to be applied on the keys
        Returns:
        the functional values of the keys
      • getBinObjectValues

        public double[] getBinObjectValues​(Function<List<T>,​Double> f)
        Applies a function to the items of each bin.
        Parameters:
        f - a function to be applied on the items
        Returns:
        the functional values of the items
      • maxBinSize

        public int maxBinSize()
        Gets the maximal size of the bins.
        Returns:
        the maximal size of the bins