Interface Arithmetic<T,D>

Type Parameters:
T - type of the element in the Arithmetic
D - type of the element resulting from dividing T by a whole number

public interface Arithmetic<T,D>
Defines the contract for Arithmetic.
  • Method Summary

    Modifier and Type
    Method
    Description
    default org.midheaven.math.ArithmeticAccumulatorCollector<T,D>
    Performs averageCollector.
    static <V, R> Arithmetic<V,R>
    of(V zero, BiFunction<V,V,V> sum, BiFunction<V,Long,R> over)
    Creates an instance from the provided value.
    over(T a, long b)
    Performs over.
    sum(T a, T b)
    Performs sum.
    default org.midheaven.math.ArithmeticAccumulatorCollector<T,T>
    Performs sumCollector.
    Performs zero.
  • Method Details

    • of

      static <V, R> Arithmetic<V,R> of(V zero, BiFunction<V,V,V> sum, BiFunction<V,Long,R> over)
      Creates an instance from the provided value.
      Parameters:
      zero - the zero value
      sum - the sum value
      over - the over value
      Returns:
      the result of applying th operation
    • zero

      T zero()
      Performs zero.
      Returns:
      the result of zero
    • sum

      T sum(T a, T b)
      Performs sum.
      Parameters:
      a - the a value
      b - the b value
      Returns:
      the result of sum
    • over

      D over(T a, long b)
      Performs over.
      Parameters:
      a - the a value
      b - the b value
      Returns:
      the result of over
    • sumCollector

      default org.midheaven.math.ArithmeticAccumulatorCollector<T,T> sumCollector()
      Performs sumCollector.
      Returns:
      the result of sumCollector
    • averageCollector

      default org.midheaven.math.ArithmeticAccumulatorCollector<T,D> averageCollector()
      Performs averageCollector.
      Returns:
      the result of averageCollector