package aalg.algebra;

import java.math.BigInteger;

/**
 * Monoid is algebraic structure with one associative binary operation. It has identity element.
 * @author Ing. Petr Ležák
 *
 * @param <T> type of elements
 */
public interface IMonoid<T extends IElement> extends IAlgebraicStructure<T> {
	/**
	 * Performs the operation.
	 * @param a operand
	 * @param b operand
	 * @return a * b
	 */
	public T operation (final T a, final T b);
	
	/**
	 * Returns identity element e.
	 * @return e; x * e = x
	 */
	public T getIdentity();
	
	/**
	 * Returns inverse element. This element may not exists, in that case method returns null.
	 * @param x operand
	 * @return y; x * y = e
	 */
	public T getInverse (final T x);
	
	/**
	 * Applies operation to repeatCount bases.
	 * @param base base element
	 * @param repeatCount number of bases
	 * @return base * base * ... * base, base is used repeatCount times.
	 */
	public T repeatOperation (final T base, final BigInteger repeatCount);
}
