Package fj.data.fingertrees
Class Measured<V,A>
- java.lang.Object
-
- fj.data.fingertrees.Measured<V,A>
-
public final class Measured<V,A> extends java.lang.ObjectDetermines 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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Measured<V,Digit<V,A>>digitMeasured()A measured instance for digits.F<A,V>measure()Returns the measuring function.Vmeasure(A a)Measures a given element.static <V,A>
Measured<V,A>measured(Monoid<V> m, F<A,V> measure)Monoid<V>monoid()Returns the monoid used to sum measures.Measured<V,Node<V,A>>nodeMeasured()A measured instance for nodes.Vsum(V a, V b)Sums the given measurements with the monoid.Vzero()Returns the identity measurement for the monoid.
-
-
-
Method Detail
-
monoid
public Monoid<V> monoid()
Returns the monoid used to sum measures.- Returns:
- the monoid used to sum measures.
-
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.
-
-