Package at.jku.ssw.fp.sect06_2
Interface Monoid<M>
-
- Type Parameters:
M
- the type of values
public interface Monoid<M>
Interface representing monoids. A monoid consists of- a set of values represented by the generic type
M
, - a identity value provided by method
identity()
, - a binary combiner function represented by method
combine
,
- Author:
- Herbert Praehofer
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description M
combine(M a, M b)
Combines two values of the monoid and returns a combined value.M
identity()
Returns the identity value.static <M> Monoid<M>
of(M idty, BinaryOperator<M> combiner)
Constructs a monoid from an identity value and an binary operator.
-
-
-
Method Detail
-
identity
M identity()
Returns the identity value.- Returns:
- the identity value
-
combine
M combine(M a, M b)
Combines two values of the monoid and returns a combined value.- Parameters:
a
- the first valueb
- the second value- Returns:
- the combined value
-
of
static <M> Monoid<M> of(M idty, BinaryOperator<M> combiner)
Constructs a monoid from an identity value and an binary operator.- Type Parameters:
M
- the type of value- Parameters:
idty
- the identity valuecombiner
- the combiner function- Returns:
- the monoid object
-
-