Class Measured<V,​A>


  • public final class Measured<V,​A>
    extends java.lang.Object
    Determines how the elements of a tree are measured and how measures are summed. Consists of a monoid and a measuring function. Different instances of this class will result in different behaviours for the tree.
    • Field Detail

      • measure

        private final F<A,​V> measure
    • Constructor Detail

      • Measured

        private Measured​(Monoid<V> m,
                         F<A,​V> measure)
    • Method Detail

      • measured

        public static <V,​A> Measured<V,​A> measured​(Monoid<V> m,
                                                               F<A,​V> measure)
      • monoid

        public Monoid<V> monoid()
        Returns the monoid used to sum measures.
        Returns:
        the monoid used to sum measures.
      • measure

        public F<A,​V> measure()
        Returns the measuring function.
        Returns:
        the measuring function.
      • measure

        public V measure​(A a)
        Measures a given element.
        Parameters:
        a - An element to measure.
        Returns:
        the element's measurement.
      • sum

        public V sum​(V a,
                     V b)
        Sums the given measurements with the monoid.
        Parameters:
        a - A measurement to add to another.
        b - A measurement to add to another.
        Returns:
        The sum of the two measurements.
      • zero

        public V zero()
        Returns the identity measurement for the monoid.
        Returns:
        the identity measurement for the monoid.
      • nodeMeasured

        public Measured<V,​Node<V,​A>> nodeMeasured()
        A measured instance for nodes.
        Returns:
        A measured instance for nodes.
      • digitMeasured

        public Measured<V,​Digit<V,​A>> digitMeasured()
        A measured instance for digits.
        Returns:
        A measured instance for digits.